Jibble

Author Topic: [SOURCE CODE] AGS Editor: Portable (No install) Version  (Read 1998 times)

helios123

  • Posts: 53
This is an attempt to make a portable version of the AGS Editor, where access to Windows Registry will be kept to a minimum. Conditional compilation is used to ensure that the same code can be used to make both the normal as well as the portable versions.

Changes made:
A new file which defines Registry and RegistryKey classes is created. The classes defined in this file mimic the methods provided by classes with the same name in the Microsoft.Win32 namespace. These classes will either access the Windows registry, or read/write from an xml file on the disc, depending upon the version (normal or portable) being built.

See the Readme for details.

The download includes only the modified files and Readme.

Note:The details about obtaining the source code of the AGS editor can be found here. The /dev folder is the
one which should be checked out.

Download here.

Comments, suggestions and criticisms are always welcome.

Edit: Apr 14, 2011: It appears that the word portable in the subject is getting interpreted as cross-platform. Hence, updated the subject line to make the nature of the code change more clear.
Please note that this is still a Windows only version of the editor, the only difference being that it has reduced dependence on the Windows Registry, enabling it to be run from removable (flash, USB, etc.) drives.

Update: Apr 30, 2011: Added null checks in code.
« Last Edit: 30 Apr 2011, 18:33 by helios123 »
That's all for now,
helios123

Wyz

  • Posts: 1,279
  • anno 1986
    • I can help with making music
    • I can help with story design
    • I can help with translating
    • I can help with voice acting
    • I can help with web design
Re: [SOURCE CODE] AGS Editor: Portable Version
« Reply #1 on: 14 Apr 2011, 01:23 »
I applaud any effort made to make programs portable. Even though I rarely use them, the moments I do I treasure that they exists, because mostly it is without warning. Such moments could be: off to relatives but I need to work on a game, or I'm testing something out real quick and need a clean environment. When they occur I'll be very happy with this I can already tell. :)

I hope this gets branched in the future, good show!
Life is like an adventure without the pixel hunts.

Armageddon

  • Posts: 1,443
  • Likes apples and nuts
Re: [SOURCE CODE] AGS Editor: Portable Version
« Reply #2 on: 14 Apr 2011, 04:52 »
Just think about it, making a game on the iPad while relaxing in your favorite chair.

Gilbert

  • Local Moderator
  • Posts: 8,857
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
Re: [SOURCE CODE] AGS Editor: Portable Version
« Reply #3 on: 14 Apr 2011, 06:01 »
This is not what the word "portable" here refers to though, if I understand your meaning.

monkey0506

  • Posts: 7,031
  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
Re: [SOURCE CODE] AGS Editor: Portable Version
« Reply #4 on: 14 Apr 2011, 07:15 »
You're right Gilbot, this isn't a version that has been ported to a non-Windows OS, and seeing as the source is still in C# (same as the "normal" AGS Editor source), it has the same limitations in OS-portability as the "normal" editor.

This source is marked as "portable" because it will use a local XML file if the system registry cannot be written to (for example, if you are running AGS from a USB drive under a Windows user that does not have rights to modify the registry)..as per the original post.

hedgefield

  • Posts: 619
  • Oh snap!
    • I can help with play testing
    • I can help with translating
    • I can help with voice acting
Re: [SOURCE CODE] AGS Editor: Portable Version
« Reply #5 on: 14 Apr 2011, 11:38 »
I'd say 'no install required' would be the gist of it, right? Not that I ever had problems running AGS on multiple PC's from one folder in my Dropbox, but it's a nice initiative, and perhaps the first step in making the engine a little more receptive to other OSes in the future.

Gilbert

  • Local Moderator
  • Posts: 8,857
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
Re: [SOURCE CODE] AGS Editor: Portable Version
« Reply #6 on: 14 Apr 2011, 14:32 »
More or less, but some portable programmes are still distributed in installer form (which are basically just self-extract archives so that you can move or copy freely the created folder anywhere). To be more exact, portability means that the programmes can be (sorta) run from anything (be it an USB thumbdrive, a removable hardisk or whatever) and anywhere (i.e. you can move it to any folder any time and even run it from another computer*), as opposed to normal modern programmes that may cease to function if you move them to other drives and folders, or another computer, apart from the ones that you installed the programmes to. Usually non-portable programmes will use some registry entries to store their info., settings, etc. but portable ones may write these information to files within the programmes' own folders, so that settings may be retained even after you start the programmes from other folders or even other computers.

*Note that, if a programme has some requirements for it to run (such as .NET framework), you still need the computers to meet such requirements to run it even if it is the portable version.

Pumaman

  • Creator of AGS
  • Posts: 10,499
  • I sense danger.
    • Lifetime Achievement Award Winner
Re: [SOURCE CODE] AGS Editor: Portable (No install) Version
« Reply #7 on: 17 Apr 2011, 15:52 »
Are there actually any Windows PC's set up to deny access to the HKEY_CURRENT_USER branch of the registry?

AGS doesn't try to write to the LOCAL_MACHINE key, and CURRENT_USER should always succeed, unless the sysadmin has gone crazy with their permission restrictions...

helios123

  • Posts: 53
Re: [SOURCE CODE] AGS Editor: Portable (No install) Version
« Reply #8 on: 18 Apr 2011, 21:31 »
Are there actually any Windows PC's set up to deny access to the HKEY_CURRENT_USER branch of the registry?

AGS doesn't try to write to the LOCAL_MACHINE key, and CURRENT_USER should always succeed, unless the sysadmin has gone crazy with their permission restrictions...


 :o That is not the reason for writing this code change.

The idea is that if you are working from a USB drive, removable harddisk, etc., the user settings, i.e. Recent games list, image editor, etc. may not always be available if the settings are read from HKEY_CURRENT_USER branch of the registry, as the data will reside on the machine and not on the removable drive.

If, on the other hand, the settings are stored on the removable device itself, then it does away with the need to set up the editor preferences if you plug your removable drive into a different machine. Also, the code change is such that paths on the removable drive can be reconstructed whenever required.

For example, let us say that when the Portable  (no install) version is run for the first time, there will be no settings.xml, and the editor will start with the default settings. Now the user configures the editor as required. Also, most of the times, the image editor and games folders will also reside on the removable drive.
While saving the settings, the drive letter (along with the colon) will be replaced with a placeholder, and while reading, it will be replaced with the drive letter which Windows has assigned to the removable drive, thus ensuring that the paths stay valid on any machine.


To make this point more clearer, please take a look at the below example, given in more detail (this is also briefly explained in the Readme available in the download archive):
Spoiler: ShowHide

Let drive letter of the removable drive is say J:.
User is running the editor for the first time. The preferences are entered and the game folder is J:\Projects\TheGame. The image editor path is J:\editors\imageedit.exe.
When the preferences are saved, the paths will be saved as {*_XMLRegistry_Drive_Replacement_String_*}\Projects\TheGame and {*_XMLRegistry_Drive_Replacement_String_*}\editors\imageedit.exe respectively.

Now suppose a different machine is used the next time, and Windows assigns K: as the drive letter to the removable drive. Then while reading from the XML, {*_XMLRegistry_Drive_Replacement_String_*} will be replaced by K:, resulting in paths which are valid on the new machine. This means that the editor will show the game folder in the 'Continue a recently edited game' dialog, as well as launch the image editor when the user wants to edit any sprites from within the editor.

Both these things cannot be possible if the settings are stored in the Windows registry under HKEY_CURRENT_USER. Also, even if the removable drive is plugged into the same machine always, there is no guarantee that it will be assigned the same drive letter all the times (e.g. a new hard disk was added, and hence the letter earlier assigned to the drive is now used for a hard disk partition, or multiple USB drives are plugged into the machine, etc.).
That's all for now,
helios123

Shane 'ProgZmax' Stevens

  • Mittens Serf
  • Posts: 5,958
  • GARBAAAAAGE DAAAAAAY!
    • I can help with animation
    • I can help with characters
    • Lifetime Achievement Award Winner
    • I can help with making music
    • I can help with proof reading
    • I can help with scripting
    • I can help with story design
    • Shane 'ProgZmax' Stevens worked on a game that won an AGS Award!
    •  
    • Shane 'ProgZmax' Stevens worked on a game that was nominated for an AGS Award!
Re: [SOURCE CODE] AGS Editor: Portable (No install) Version
« Reply #9 on: 20 Apr 2011, 04:23 »
This is a grand idea.  I love portable versions of apps as they are much easier to backup and re-use on demand.