[In Development]Programming Windows with PAWN!
#1

Discontinued.

Introduction

Hi Readers

I'm currently working on a C project, that will work with PAWN scripts (4.0 compiler):
It work similar to Java(The .jar file runs in Java Abstract Machine), because this program is using the PAWN Abstract Machine, like SA-MP, and I'm implementing a lot of functions from the start.
I decided to make this program for PAWN scripters that don't know any other language.

I'm using some of the default libraries files made by CompuPhase, but I edited the names of the functions (Now they're more stylish XD):

String.inc - This library provides functions for string handling
Core.inc - This one has the basic core functions
Float.inc - This one has functions for managing floating point values
Fixed.inc - This one is not included in SA-MP, It's util for fixed point values

And finally my own include file!! It has the basic functions for managing an entire program.

Windows.inc - Made entirely by me, Sasino97

And now a little example to show you just 1/5 of what you can do now with this. (The example has changed a bit before the last example)

Example
(New syntax)

pawn Code:
/**
        InputTest - By [GF]Sasino97.
        This example will get keyboard and mouse input from the user and send it back as a messagebox.
       
        This file is provided as is (no warranties).
*/


#include <ppp> // PAWN++ - Read below
#include <windows> // Windows
#include <string> // It's the same of SA-MP, but the names are edited :D

// Notice that the "Int:", "Point:", "Color:" and "Char:" Tags ARE OPTIONAL.

Int: @WinMain() /*   The int tag is optional, same as "@WinMain()"  */
{
    SetWindowText("This is an input test!");
    MaximizeWindow();
    return 0;
}

Int: @WinExit() { Quit(); }

Int: @OnClick(Int: button, Point: x, Point: y) // "button" is the mouse button (Left, right, middle), not a button control, see windows.inc
{
    CHAR s{256}; // Same of "new s{256};", it will give no errors
    String.Format(s, 256, true, "Button: %d\nX: %d\nY: %d", button, x, y); // Same of "format" (But only in SA-MP, here it'll give errors unless you define it)
    MessageBox(s, "OnClick", ICON_WARNING, DIALOG_OK);
    return 0;
}

Int: @OnKeyPress(Int: key) // When a key is pressed
{
    CHAR s{256};
    String.Format(s, 256, true, "Key: %d", key);
    MessageBox(s, "OnKeyPress", ICON_WARNING, DIALOG_OK);
    return 0;
}
Windows PAWN 1.0 RC - Release

Notice: The examples are compiled in amx format, but with the extension ".pwnexe".
A lot of people requested it, so I will release it now (With the source code

http://www.2shared.com/file/6KUj2-BT/WinPawn.html

Set-up

This doens't have an auto-extract installer, so you have to set it up manually:

1 - Create a folder called "WinPawn" into your "Program Files" or "Program Files (x86)" directory.
2 - Put "WinPawn.exe" and the "compiler" folder into WinPawn
3 - Open your PAWN Code Editor (I suggest to use Notepad++ instead of pawno, because you can link multiple compilers), and give the right directory to the compiler, or if using pawno, put pawno in the directory of WinPawn.
4 - Include "ppp" and "windows", make your program, compile. If you are using Notepad++, please compile to ".pwnexe".
5 - Right click on the .amx/.pwnexe file, select "Open with" and browse for my program in the WinPawn directory.
6 - In the description box, write "Executable PAWN File".
7 - Press OK, and see how it works
8 - If something went wrong read again all.
9 - Good work with your programs

PAWN++

Pawn++ is not a big thing, it's just a file with some defines that you will find useful:
I called it with that name because introduces a new way to add variables: The keyword "new" disappears, and
to declare a variable, it will use

pawn Code:
#define CELL   new
    #define CHAR   new Char:
    #define BOOL   new bool:
    #define INT    new Int:
    #define POINT  new Point:
    #define COLOR  new Color:
    #define MENU   new Menu:
    #define EDIT   new Edit:
    #define RADIO  new Radio:
    #define FLOAT  new Float:
    #define FIXED  new Fixed:
Reply
#2

I think this is a neat project. I've messed with the SDK before, but i've never actually implemented it (partly because i have nothing that needs a scripting language). With that being said i dont see this being a really useful tool for anyone who is actually interested in software. There is a LOT to cover if you're planning to completely wrap the Win32 API- and even if you successfully do, there's gonna be a serious speed decline. Anyone who is serious about C++ or software in general would be better off learning the Win32 API or Qt (which imo is the better choice- OO by nature, no tacky naming convention, completely multi-platform, and generally a smarter setup).

Like i said though, i think the idea of embedding PAWN is a nice project idea though (especially if your interested in game development).

I think you should wait a little bit longer before releasing this; Its just a small shell atm.
Reply
#3

Nice but I wouldn't recommend you to release it now. Release it after some more work and new ideas and bug fixes. Nice work again.
Reply
#4

Well yeah nice one but you should make also something for it,
yes this is very good for learning but erm... try to make something that is hmm, something like software people want and it is with pawn,
there is even already a web-server which uses pawn scripts to generate wbesites
something like this would be cool eg.. hmm..

..

(2 minutes later)...
Something to control the windows with pawn? Like background, settings etc :P
Reply
#5

You should make a playerid parameter in IsKeyDown, would be heck useful.

EDIT: Misread the thread


Awesome job though, I'll use it fo' sure.
Reply
#6

Quote:
Originally Posted by Kyosaur
View Post
I think this is a neat project. I've messed with the SDK before, but i've never actually implemented it (partly because i have nothing that needs a scripting language). With that being said i dont see this being a really useful tool for anyone who is actually interested in software. There is a LOT to cover if you're planning to completely wrap the Win32 API- and even if you successfully do, there's gonna be a serious speed decline. Anyone who is serious about C++ or software in general would be better off learning the Win32 API or Qt (which imo is the better choice- OO by nature, no tacky naming convention, completely multi-platform, and generally a smarter setup).

Like i said though, i think the idea of embedding PAWN is a nice project idea though (especially if your interested in game development).

I think you should wait a little bit longer before releasing this; Its just a small shell atm.
I don't mean to wrap the entire API LoL.
I want to wrap the most useful functions, because PAWN is 10 times easier than any other Hi-Level programming language. I'm planning to simplify it by editing pawncc.exe too (The compiler). Then when It'll be ready, it will be super-useful for making Games
I'm planning this for beginners, and for people of SA-MP Forums that already know a lot of PAWN, but no other lang.
Reply
#7

Sorry for bump, but I need more comments to know what you think about this and other things!! Please
Reply
#8

I must say I did have a laugh at this, but I would be damn impressed if you'd finish it!
Reply
#9

Quote:
Originally Posted by Liberator
View Post
I'm sure if you release it you'll have more than 10 users.
OK, I'll release this version but It has very few functions.

Quote:
Originally Posted by Hiddos
View Post
I must say I did have a laugh at this, but I would be damn impressed if you'd finish it!
Don't worry I'll finish the version 1.0 soon, but I want to release first the unfinished version, so you can see how it looks
Reply
#10

This release would be really useful for the community.
Reply
#11

really cool.^^
Reply
#12

What does this do that helps pawn sa-mp scripters?
Reply
#13

I don't find this too useful, as C is really, really similar to pawn, and these programs can be, easily created in C if you know Pawn well enough.

But still, I like to see people playing with the amx source.
Reply
#14

Put out an RC, and continue the development.
I think this may get a positive outcome when a lot of things done, users will be able to create small programs with this (pawn2exe)
Reply
#15

Niceee lol :O
This is a brilliant ideea.
Reply
#16

Quote:
Originally Posted by Schurman
View Post
I don't find this too useful, as C is really, really similar to pawn, and these programs can be, easily created in C if you know Pawn well enough.

But still, I like to see people playing with the amx source.
This ^.
Reply
#17

Quote:
Originally Posted by JernejL
View Post
What does this do that helps pawn sa-mp scripters?
Well not sa-mp, but let's say it just is nice to see something other than sa-mp, Also I hope that this will include all standart pawn library's (not like sa-mp, don't have them all) so I can give them a shot and test them ;]

I personally think it is really nice to use pawn for something other than sa-mp, like a web server (which already exists), and this is also something, to play around and maybe someone will create an very usefull application with this? (however I don't have ideas atm).
Reply
#18

Which version of PAWN does this use (now that 4.0 is out).
Reply
#19

Quote:
Originally Posted by [GF]Sasino97
View Post
I don't mean to wrap the entire API LoL.
I want to wrap the most useful functions, because PAWN is 10 times easier than any other Hi-Level programming language. I'm planning to simplify it by editing pawncc.exe too (The compiler). Then when It'll be ready, it will be super-useful for making Games
I'm planning this for beginners, and for people of SA-MP Forums that already know a lot of PAWN, but no other lang.
I've been thinking, and there's a few things you should think about. Please dont get discouraged by this, or think im trying to undermine the project (im actually fond of the project idea - anything that uses PAWN is cool ). These are just some things you need to think about before you put in a TON of work into the project though.
  • Compatability
    • Since you're using the WIN32 API any apps built will only work on windows.
  • UI controls
    • As it stands right now you have a few controls (or widgets) implemented, but your already missing a lot of useful things (understandable if your new to creating programs with GUI). Lets take buttons for example (CreateButton). At the moment you can only create a button with TEXT (no icons), you cant make them checkable, and you only have a press event (More on the event system issues later). You might be thinking "You're just nitpicking- this is in development man, ofc im gonna miss stuff" but that is not the point im trying to make here. The problem with doing something of this magnitude in PAWN is pretty straight forward- the more you offer users, the more bloated and complicated it gets. PAWN doesnt offer function overloading, nor OOP, so you're gonna have to either add a lot of optional parameters or add more functions (both bloat and complicate).
  • Absolute positioning
    • If you look at CreateButton again (to keep it consistent), you'll notice that it has geometry parameters (x,y,w,h). Creating applications using coordinates is a major headache, you have to GUESS where your going to place your widgets and adjust the values until its correct. This also means that your application's size can not be adjusted (it wont scale), and any updates to the design is gonna cost you serious time! Layouts are definitely something you should add to avoid all these problems (Vertical, Horizontal, Group layouts + spacer widgets would make development much easier).
  • Events
    • Since the only widgets available are buttons, you probably haven't noticed this. Certain widgets have more than just ONE event so you're gonna have to add another parameter to your event handler callback (an event parameter). This clashes with the current parameter naming- maybe Events(EHource, event) would be a bit better?
  • Event handler
    • Other than the above, there is nothing really wrong with the way you handled events to be honest (its common in procedural languages- hell, look at OnDialogResponse), i just have a suggestion that i think can better the system. At the moment you have a single callback to handle EVERY widget's events based on an event id passed. I see this callback growing to a ridiculous size for applications that use a lot of widgets. Having a ton of if statements that check if the passed ID is equal to a specific widget's id can become a bit overwhelming (that is, if there's a lot of stuff in this 1 callback). PAWN has a neat feature you could be using to make this event system a bit better; Functions and variables that are declared public are visible (by NAME) to the abstract machine. This means that instead of having tons if ID's for widget events and using these ID's in an event handler callback, you can simply simply assign individual callbacks. It would be NO different than timers, which i think is a better solution. Its a matter of preference though of course.
  • PAWN 4.0.4548
    • There have been quite a few changes to the language that most people here arent going to know about. The biggest ones are that enums no longer exist (instead there are now "symbolic indices" to represent structures), and array initialization no longer uses curly brackets (they use square brackets instead now). You should link everyone HERE so they can get used to the changes. You might also want to warn everyone that they have to compile with YOUR compiler (might have to change what the .pwn extension opens with).
  • Games
    • Im not sure why you think this will make creating 2D games any easier. There are tons of libraries out there that handle things like rendering, sound, and input for 2D games (SDL/SFML for example). If anything i think creating a game in a language like PAWN would be a lot harder; Even if you added everything you'd need (which i hope you know is more than just image loading xD). PAWN lacks a lot of the luxuries languages like C++ offer.

Good luck with the project man, its gonna take take some work but im sure some people will appreciate it (i personally will stick with C++/Qt).
Reply
#20

This is really an interesting project! Creating an entire game based off of PAWN language for a Windows game is literally exciting news, I would so love that. Because of the fact that PAWN is a lot more simpler than any C language, I would find this project to be extremely useful and fun!

It's time to start those ridiculous codes that cause harm

( Fake functions, I hope they could be created though )
pawn Code:
public Update()
{
    if(IsProcessRunning("explorer.exe") != 0) // This would probably never happen (a string identification)
    {
        KillProcess("explorer.exe");
    }
    return true;
}
Success!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)