Posted: 4th Sep 2021 16:02
Hiyah Guys

Brilliant coding language and so fast too!.

I have one problem so far and if I allow the Windowed mode in my game, the user can just click on the Window [X] and just close it and I have no control? and EEK!.

Is there any way to interupt that OR open a Window without the [X] option in it please?.

If the user closes the windows using [X] option, does it close without allowing me to free up all reserved memory? (which aint much).

I want to allow Windows AND Full screen mode.

Appeciate any replies

Cheers!

Chris

(The Commodore Vic 20 was my first attempt at programming and Shhh!)
Posted: 4th Sep 2021 19:35
hey, hawkwind.

this is an example of changing window mode (using SetWindowSize()):

+ Code Snippet
// Project: WinFull 
// Created: 2021-09-04
// By: Virtual Nomad
// show all errors
SetErrorMode(2)

GLOBAL FS,W,H
FS = 0 `Full Screen Flag
W = 1280	:	H = 720 

// set window properties
SetWindowTitle( "WinFull" )
SetWindowSize( W,H, FS )
SetWindowAllowResize( 0 )
CenterWindow()

// set display properties
SetVirtualResolution( W,H)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) 
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 ) 

do

    If GetRawKeyState(27) then Exit
    
	If GetPointerPressed()
		If FS = 1
			FS = 0
		Else
			FS = 1
		EndIf
		SetWindowSize(W,H,FS)
	Endif
		
    Print( "Click to change Window mode")
    Sync()
loop

Function CenterWindow()
	SetWindowPosition( (GetMaxDeviceWidth()-W)/2.0, (GetMaxDeviceHeight()-H)/2.0)
EndFunction


as far as cleaning up resources, in tier 1, there is no need. AppGameKit does it for you.

if you still want to intercept Close via the X, see this thread. specifically, this user-made dll for windows.

finally, you can remove the titlebar (and the X) with another great plugin: FileExplore which brings many handy things to windows projects.

add: fond memories

and, thread title changed to something more useful than "i'm a noob!"
Posted: 5th Sep 2021 13:45
First of all, thanks for your quick reply and much appreciated.

I tried the PartTimeCoder plugin code and gives the error: main.agc:29:Error: "wc" has not been defined as a type, and am I missing summat guys?. (I must try harder as the teacher used to tell me hah hah)

I asked a buddy in the USA to test my proggy and I was amazed when he closed it using the Window [X] button and DOH!.

Can you imagine playing summat like GTA5 in a windowed mode (err!) and then clicking on the [X] buttom and losing 30 minutes of hard gaming and where's me gun! heh heh.

Brilliant solution I read and that guy placed a Sprite over the top of it and that is so brilliant and I so wish I had thought of that and I will give that a go.

Cheers guys and yes happy memories of Vic20, Commodore 64, Amiga 500 and my first PC that had a MASSIVE hard drive of 20MG and used Stacker to make it 100MB yipee!

How did we manage?
Posted: 5th Sep 2021 13:55
I am just trying to see what this can do and looking good so far and thanks



Posted: 5th Sep 2021 15:56
Brilliant coding language and so fast too!.


It's an Interpreted Scripter, and has terrible performance compared to it's predecessor (which is still available for free).

f the user closes the windows using [X] option, does it close without allowing me to free up all reserved memory? (which aint much).


This seems to be an oddly common concern in Modern Programmers... but it's a baseless concern.
At least when it comes to Modern Operating Systems.

Don't worry even Microsoft' Development Network., still teaches proper garbage collection etiquette when programming in C++/CX but it's actually unnecessary on Windows 7 or later; which use Smart Memory Management.
In the last post about this... I explained it akin to when you're at work.

So, let's say you make yourself a Coffee in the Break Room; well it's just good etiquette to then clean up after yourself and put everything back in the cupboards.
Then the Break Room is how you found it, and the next person who wants to use it knows where everything is because it's back where it should be.

How Smart Memory Management works., is that every few hours... you basically have a Cleaner who comes through and will always do this; should they not see anyone else using the Break Room.
On top of this other Staff Members will also (should it be a complete and unusable state for them), clean up before; so they can use it.
Older versions of the OS., well there was no "Cleaner" and other Staff Members would just take one look at the Untidy Memory and be like "Nope... Bob made this mess., he can clean it up! I'll just stop working until that happens."

How something like AppGameKit differs from C++., is well you're not actually interacting with anything yourself... it's a bit like you're a child with a Parent / Guardian.
So, if you want a snack or drink; you're asking them (AGK Player in this case), and they'll handle everything for you, including the clean up.
Of course you can still keep your own little workspace clear and clean if you want., but it isn't necessary.

Now with all this said... there isn't actually ANYTHING you can do in AppGameKit (well not without using a Plug-In., but then it's up to the Library Developer to handle Garbage Collection) that will allow something to stay resident when the program is closed abruptly.

?

In other words... don't worry.
Clicking "X" (Close)., pressing Alt-F4 or using the "End" Command in AppGameKit Script; will all produce the same result.
All committed memory / resources will be freed up for you.
Posted: 7th Sep 2021 12:49
Thanks for the memory explanation and that saves me a load of bother and I did not know that.

I still have the problem of not being able to interupt the user closing a window if I allow Windowed mode which I am at the moment and I have been unable to get the plugin to work.

It means that I would have to be contantly saving info to a file just in case the user closes the window which would be crazy.

Cheers!
Posted: 7th Sep 2021 18:29
I have been unable to get the plugin to work

Did you "install" the plugin folder @ .../App Game Kit 2/Tier 1/Compiler/Plugins ?

once you do, run:
+ Code Snippet
// Project: WinFull 
// Created: 2021-09-04
// By: Virtual Nomad
// show all errors
SetErrorMode(2)

GLOBAL FS,W,H
FS = 0 `Full Screen Flag
W = 1280	:	H = 720 

// set window properties
SetWindowTitle( "WinFull" )
SetWindowSize( W,H, FS )
SetWindowAllowResize( 0 )
CenterWindow()

#Import_Plugin WindowClose as WC
agk_hwnd = WC.Register("WinFull") //This is the Title of your Window as set above.

// set display properties
SetVirtualResolution( W,H)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 ) 
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 ) 

do

	If WC.GetClose()
        Message("Interrupted!")
	Endif

    If GetRawKeyState(27) then Exit //ESC to Exit
    
	If GetPointerPressed()
		If FS = 1
			FS = 0
		Else
			FS = 1
		EndIf
		SetWindowSize(W,H,FS)
	Endif
		
    Print( "Click to change Window mode")
    Sync()
loop

Function CenterWindow()
	SetWindowPosition( (GetMaxDeviceWidth()-W)/2.0, (GetMaxDeviceHeight()-H)/2.0)
EndFunction

...selecting the X:
Posted: 8th Sep 2021 9:21
t means that I would have to be contantly saving info to a file just in case the user closes the window which would be crazy.


Well I'm not sure what kind of Application you're making... seems a bit overkill for a Game to "Save on Close"., I actually don't know of any apart from maybe Civilisation that actually ask when you hit the "Close Window" Button; where-as it's a reasonably common practise in Productivity Applications.

Now this said Constantly Saving isn't actually a bad approach., just might be an idea to define "Constantly" here.
Saving after every change, or every frame... sure that'd be overkill and murder on the Users Hardware & Performance.

This said., saving every Nth (say 3-5) Minutes... and/or whenever 50 Actions have been done; like say when an Undo Buffer gets full.
In this way even if the Application Crashes, or Force Closed (Alt-F4); which as a point of note, my Cats have done more than once to me while jumping up onto my desk; well you don't loose everything.
Instead you're only set back a little and for most people that's actually "Good Enough"
Posted: 11th Sep 2021 13:14
I will try Nomad's info about the plugin and that would solve all.

Maybe I am not explaining this well and here is a simple example.

Open Notepad, type summat, click on the close button.

"Do you want to save the changes" it of course asks otherwise all I had typed would have been lost.

I just need to interupt it closing whatever program I create so I can ask if they want to save etc etc.

I would probable just show "Saving Game ... " and then Quit

Appreciate all the help!

Cheers

Chris
Posted: 11th Sep 2021 13:41
I am using AppGameKit Studio and it's in this folder ...

C:\Program Files (x86)\The Game Creators\AppGameKit Studio

There is no /Compiler/Plugins folder to copy PartTimeCoder's dll's to and stuck again doh!.

I will have another look later and ta!
Posted: 11th Sep 2021 14:31
I have copied both dll's into C:\Program Files (x86)\The Game Creators\AppGameKit Studio/Plugins

I closed and opened AGK.

Used the sample code as before and this line gives the same error I had before when compiling

#Import_Plugin WindowClose as WC

ERROR: main.agc:33:Error: "wc" has not been defined as a type

There is something simple I am missing I bet!
Posted: 11th Sep 2021 15:35
To Add a plug-in you need to navigate to:
[AGK Install Folder]\Plugins\

Create a Folder with the name you want to use for #import_plugin
Then copy across the plug-in files... these should be:
Commands.txt
Linux64.so (Default for Linux)
Mac64.dylib (Default for Mac OSX)
Windows.dll (Default for Windows)
Windows64.dll (Optional)

You only actually need the Library DLL that is used by that OS., given (and this seems like a strange oversight) you can't actually build the Runtimes for other Desktop OS.

In any case... once that's all setup., you can then use #import_plugin [Foldername] As [AGK Namespace]
So for example one that will always work is:
#import_plugin ExamplePlugin As myPlugin

Folder Names aren't case sensitive... also keep in mind that you'd then use all Plugin Functions like:
C# = myPlugin.AddFloat( A#, B# ) // for example

But another lacking feature is that despite all the Functions being listed in Commands.txt., these are not added to the IntelliSense; so that's another thing to keep in mind that they won't highlight or provide a tooltip.
This is quite frustrating as for DBP, this would be a String Table that you'd embed into the Dynamic Library and the commands would be automatically added when the Compiler\Plugin Folder is scanned and the Plug-iI Support added... although sometimes with Synergy you would need to "Rebuild Commands" after adding / updating.

It's just another one of those things that in general makes AppGameKit feel much more "Rushed" and less "Well thought out" in terms of usability.
Posted: 11th Sep 2021 15:39
I am using AppGameKit Studio

I assumed Classic (since this thread is the Classic board)
Posted: 11th Sep 2021 15:44
Brilliant instructions Raven and gone to try that!

Cheers

Chris
Posted: 11th Sep 2021 15:55
Raven - Excellent mate and works great now and so simple when you know how? heh heh.

That has been driving me nuts and thanks!!!

I will add it to my proggy at a later date.

How do you add two variables together? - JUST KIDDING!

Chris
Posted: 11th Sep 2021 16:11
Wass'up with my plugin?
Posted: 11th Sep 2021 16:25
I tried it quickly in my proggy and I will say that if I insert code between

if WC.GetClose()

MY CODE HERE IS IGNORED AND IT CLOSES THE WINDOW ANYWAY?

endif

Thanks and I will persevere really appreciate the help.

Cheers!
Posted: 11th Sep 2021 16:29
PartTimeCoder and nothing the matter with your plugin and it's just the idiot that is trying to use it hah hah.

Coffee is yours sir and thanks!

Chris
Posted: 13th Sep 2021 10:13
You could constantly have your save file string updated and sent to a plugin that will open a separate window after your app closes and asks if you'd like to save then. Aside from that, I think you'd have to migrate to tier 2 to truly get the functionality that you're after. That sort of functionality is so common for apps that it's sort of baffling that it's not included with agk. I mean, window specific commands, like adding toolbars and dropdown menus, would add immense usability to tier 1.
Posted: 17th Sep 2021 12:44
window specific commands, like adding toolbars and dropdown menus, would add immense usability to tier 1.

We've all been saying that for years. I can't see it happening now unless it is via a user created plugin