Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Recovering memory and Close intercept

Author
Message
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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!)



Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 4th Sep 2021 19:35 Edited at: 4th Sep 2021 20:01
hey, hawkwind.

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



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!"
[My Itch.io Home] [Community Apps on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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?
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
Posted: 5th Sep 2021 13:55
I am just trying to see what this can do and looking good so far and thanks



Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 5th Sep 2021 15:56
Quote: "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).

Quote: "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)."


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.
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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!

If this part is for info about me, I can add that and is it?
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 7th Sep 2021 18:29 Edited at: 7th Sep 2021 18:32
Quote: "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:

...selecting the X:
[My Itch.io Home] [AGK on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]

Attachments

Login to view attachments
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 8th Sep 2021 09:21
Quote: "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."


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"

HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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
If this part is for info about me, I can add that and is it?
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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!
If this part is for info about me, I can add that and is it?
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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!
If this part is for info about me, I can add that and is it?
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
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.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 11th Sep 2021 15:39
Quote: "I am using AppGameKit Studio"

I assumed Classic (since this thread is the Classic board)
[My Itch.io Home] [AGK on Itch.io]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=agk] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[AGK Showcase][Google Forum Search]
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
Posted: 11th Sep 2021 15:44
Brilliant instructions Raven and gone to try that!

Cheers

Chris
Using 2 Dell XPS 15 9570 laptops Windows 10 for programming. Still have my ancient gaming rig (Geforce GTX 980ti) which I gave up updating when I bought a PS4 Pro which has now been replaced with PS5.
Learnt the BASIC language on Vic20 and that woke me up and then on many others. Learnt Borland C++ without the C++ a million years ago and loved it but not used it since and "too old man!" - hah hah
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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
Using 2 Dell XPS 15 9570 laptops Windows 10 for programming. Still have my ancient gaming rig (Geforce GTX 980ti) which I gave up updating when I bought a PS4 Pro which has now been replaced with PS5.
Learnt the BASIC language on Vic20 and that woke me up and then on many others. Learnt Borland C++ without the C++ a million years ago and loved it but not used it since and "too old man!" - hah hah
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 11th Sep 2021 16:11
Wass'up with my plugin?
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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!
Using 2 Dell XPS 15 9570 laptops Windows 10 for programming. Still have my ancient gaming rig (Geforce GTX 980ti) which I gave up updating when I bought a PS4 Pro which has now been replaced with PS5.
Learnt the BASIC language on Vic20 and that woke me up and then on many others. Learnt Borland C++ without the C++ a million years ago and loved it but not used it since and "too old man!" - hah hah
HawkwindUK
11
Years of Service
User Offline
Joined: 30th Jan 2013
Playing: Grand Theft Auto V (again) in 4K when it comes out on PS5
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
Using 2 Dell XPS 15 9570 laptops Windows 10 for programming. Still have my ancient gaming rig (Geforce GTX 980ti) which I gave up updating when I bought a PS4 Pro which has now been replaced with PS5.
Learnt the BASIC language on Vic20 and that woke me up and then on many others. Learnt Borland C++ without the C++ a million years ago and loved it but not used it since and "too old man!" - hah hah
IronManhood
9
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
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.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Sep 2021 12:44
Quote: "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
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 17th Sep 2021 13:34
I started it, may pull some kind of funding thing to get it completed as its a lot of work and I need to eat.

All the users demanding a UI system and talking of subscription nonsense and such .. are you willing to back a user developed UI plugin ??, if you back it, I will build it.

The current state of my WinUI plugin is: v0.4a (functional but incomplete)
Quote: "
Misc Functions
void WinUI.Init()
integer WinUI.GetWindowHandle(string window_title)
integer WinUI.HIWORD(integer Param)
integer WinUI.LOWORD(integer Param)

Window Functions
integer WinUI.OpenWindow(integer id, integer x, integer, y, integer, width, integer height, string title, integer flags, integer parent)
void WinUI.CloseWindow(integer id)
void WinUI.SetWindowVisible(integer id, integer state)
integer WinUI.GetWindowVisible(integer id)
void WinUI.SetWindowEnabled(integer id, integer state)
integer WinUI.GetWindowEnabled(integer id)
void WinUI.SetWindowState(integer id, integer state)
integer WinUI.GetWindowState(integer id)
void WinUI.SetWindowTitle(integer id, string title)
string WinUI.GetWindowTitle(integer id)
void WinUI.SetWindowSize(integer id, integer width, integer height)
integer WinUI.GetWindowWidth(integer id)
integer WinUI.GetWindowHeight(integer id)
void WinUI.SetWindowPosition(integer id, integer x, integer y)
integer WinUI.GetWindowX(integer id)
integer WinUI.GetWindowY(integer id)

Object Create Functions
integer WinUI.CreateButton(integer id, integer x, integer, y, integer, width, integer height, string title, integer default, integer toggle)
integer WinUI.CreateCheckBox(integer id, integer x, integer, y, integer, width, integer height, string title, integer 3state, integer auto)
integer WinUI.CreateOption(integer id, integer x, integer, y, integer, width, integer height, string title, integer auto)
integer WinUI.CreateGroupBox(integer id, integer x, integer, y, integer, width, integer height, string title)
integer WinUI.CreateText(integer id, integer x, integer, y, integer, width, integer height, string title)
integer WinUI.CreateInput(integer id, integer x, integer, y, integer, width, integer height, string title)
integer WinUI.CreateComboBox(integer id, integer x, integer, y, integer, width, integer height, string cue_banner)
integer WinUI.CreateComboEdit(integer id, integer x, integer, y, integer, width, integer height, string cue_banner)
integer WinUI.CreateListBox(integer id, integer x, integer, y, integer, width, integer height, integer multiselect)
void WinUI.FreeObject(integer id)

Misc Object Functions
integer WinUI.GetObjectType(integer id)
integer WinUI.GetObjectHWND(integer id)

Object Functions
void WinUI.SetObjectText(integer id, string text)
string WinUI.GetObjectText(integer id)
void WinUI.SetObjectState(integer id, integer state)
integer WinUI.GetObjectState(integer id)
void WinUI.SetObjectData(integer id, integer value)
integer WinUI.GetObjectData(integer id)
void WinUI.SetObjectSize(integer id, integer width, integer height)
integer WinUI.GetObjectWidth(integer id)
integer WinUI.GetObjectHeight(integer id)
void WinUI.SetObjectPosition(integer id, integer x, integer y)
integer WinUI.GetObjectX(integer id)
integer WinUI.GetObjectY(integer id)

Object Item Functions
integer WinUI.AddObjectItem(integer id, sinteger index, tring text, integer image, integer flags)
void WinUI.RemoveObjectItem(integer id)
integer WinUI.CountObjectItems(integer id)
void WinUI.ClearObjectItems(integer id)
void WinUI.SetObjectItemText(integer id, integer item_index, string text)
string WinUI.GetObjectItemText(integer id, integer item_index)

Event Functions
integer WinUI.EventBegin()
void WinUI.EventEnd()
integer WinUI.GetEvent()
integer WinUI.GetEventType()
integer WinUI.GetEventWindowID()
integer WinUI.GetEventObjectID()
integer WinUI.GetEventWParam()
integer WinUI.GetEventLParam()

Menu Functions
integer WinUI.CreateMenu(integer window_id)
integer WinUI.AddMenuTitle(integer menu_id, integer item_id)
integer WinUI.AddMenuItem(integer menu_id, integer item_id)
void WinUI.UpdateMenu(integer window_id)"
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-11-21 18:06:15
Your offset time is: 2024-11-21 18:06:15