Author Topic: C# AGI Interpreter  (Read 1614 times)

0 Members and 1 Guest are viewing this topic.

Offline MusicallyInspired

Re: C# AGI Interpreter
« Reply #30 on: January 22, 2017, 09:43:06 AM »
Am I the only one who hates it when games save games in user profile folders? I'd rather they just stay in the interpreter folder.
Brass Lantern Prop Competition

Offline Kawa

Re: C# AGI Interpreter
« Reply #31 on: January 22, 2017, 10:01:35 AM »
To be fair, if the application is running from Program Files, it may not be allowed to save in its own startup location.

Offline MusicallyInspired

Re: C# AGI Interpreter
« Reply #32 on: January 22, 2017, 10:39:55 AM »
Who actually uses Program Files for things like this?
Brass Lantern Prop Competition

Offline troflip

Re: C# AGI Interpreter
« Reply #33 on: January 22, 2017, 11:05:47 AM »
Oh yes please, more games should use that location instead of mucking up My Documents. I have some minimal C# code if you need it, since last I checked System.Environment's locations list didn't have it.

You can get the "SaveGame" folder by PInvoke'ing the native apis (SHGetKnownFolderPath with FOLDERID_SavedGames (which only works on Vista and later) ):
http://stackoverflow.com/questions/3795023/downloads-folder-not-special-enough/3795159#3795159

Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Kawa

Re: C# AGI Interpreter
« Reply #34 on: January 22, 2017, 12:40:33 PM »
That's what I do, actually.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #35 on: January 22, 2017, 12:54:58 PM »
This whole area is yet another thing that I know nothing about. All my commercial experience is with writing server side Java code for web applications that run on Linux. So whenever I dabble with desktop apps, I'm stackoverflowing things most of the way through.

So I'll let you guys reach a consensus on this and I'll go with whatever you think is best practice. If you do have some sample C# code for when I need it, that would be great.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #36 on: January 22, 2017, 01:05:57 PM »
Sounds like you are making good progress. Perhaps too soon, but one thought just occurred to me. For a new interpreter it would be a good idea to have the save directory default to the user space, say "C:\Users\<User_Name\Saved Games\<Game_Name>".

Yeah, it probably is too soon at the moment. Saving games is one of those things towards the end of the list, along with Sound. I might even tackle sound before saved games. Sound in C# is obviously another thing I know nothing about, so that will be interesting  :)

The saved game topic does raise an interesting question though. I guess I should probably be saving in the original AGI saved game format. Hadn't really thought about that until now.

I got the controllers and set.key working nicely last night. This evening I might look at a couple of bugs and then maybe at implementing the inventory screen.

Offline Collector

Re: C# AGI Interpreter
« Reply #37 on: January 22, 2017, 01:19:40 PM »
Who actually uses Program Files for things like this?

This was an issue with Sunlight Games when I did the Gold Rush! package for them. They wanted the default for to be installed in the %ProgramFiles% directory. They only relented after I explained the permissions problems with legacy games in a system folder. You have to think of the range of types of users that may install your game. If it is installed inside of the %ProgramFiles% directory with UAC on the save games would just end up in the Virtual Store, not the game's folder. I would also note that the Save Game folder in the user space is best for a multi-user situation so that different users can have their own save games that won't be over written by another user.

The Save Games folder is where ScummVM, AGS and most newer game engines default. It is simply modern best practices. Though if this is done with this new interpreter I would not mind a configuration setting or switch to allow another location. ScummVM does allow this.

But all of this is far too early for much consideration at this point in the development of the new interpreter.
KQII Remake Pic

Offline Collector

Re: C# AGI Interpreter
« Reply #38 on: January 22, 2017, 02:05:31 PM »
This whole area is yet another thing that I know nothing about. All my commercial experience is with writing server side Java code for web applications that run on Linux. So whenever I dabble with desktop apps, I'm stackoverflowing things most of the way through.

So I'll let you guys reach a consensus on this and I'll go with whatever you think is best practice. If you do have some sample C# code for when I need it, that would be great.

Many of the special folders paths can be obtained with just:

System.Environment.GetEnvironmentVariable("USERPROFILE");

It is good enough for getting the main special folders such as the user profile, documents, temp, etc., but it does not get all special folders. Here is a CodeProject page with sample code in C# for getting *all* special folders in .NET. https://www.codeproject.com/articles/878605/getting-all-special-folders-in-net
KQII Remake Pic

Offline Collector

Re: C# AGI Interpreter
« Reply #39 on: January 22, 2017, 02:10:34 PM »
Yeah, it probably is too soon at the moment. Saving games is one of those things towards the end of the list, along with Sound. I might even tackle sound before saved games. Sound in C# is obviously another thing I know nothing about, so that will be interesting  :)

The saved game topic does raise an interesting question though. I guess I should probably be saving in the original AGI saved game format. Hadn't really thought about that until now.

I got the controllers and set.key working nicely last night. This evening I might look at a couple of bugs and then maybe at implementing the inventory screen.
I would consider to important to to have it compatible with the original AGI save game format. We would want it to work with official games.

Would trying to port the Visual AGI Sound Editor to C# help with tackling AGI sound in C#?
KQII Remake Pic

Offline Kawa

Re: C# AGI Interpreter
« Reply #40 on: January 22, 2017, 03:16:24 PM »
Code: [Select]
//From my game

public static class Vista
{
public static bool IsVista = (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6);

public static readonly Guid SavedGames = new Guid("4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4");
//You could add more, but most of them are natively supported by Environment.SpecialFolder.

public static string GetKnownFolderPath(Guid target)
{
if (!IsVista)
return null;

string ret = null;
IntPtr pPath;
try
{
if (SafeNativeMethods.SHGetKnownFolderPath(SavedGames, 0, IntPtr.Zero, out pPath) == 0)
{
ret = System.Runtime.InteropServices.Marshal.PtrToStringUni(pPath);
System.Runtime.InteropServices.Marshal.FreeCoTaskMem(pPath);
}
return ret;
}
catch (DllNotFoundException)
{
return null;
}
}
}

internal static class SafeNativeMethods
{
[DllImport("shell32.dll")]
public static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr pszPath);
}

Code: [Select]
//Untested -- savePath will be "Saved Games\foo", "AppData\Local\foo", or "~/.config/foo" depending on the OS.
savePath = Path.Combine(Vista.GetKnownFolderPath(Vista.SavedGames) ?? Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), gameName);

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #41 on: January 27, 2017, 01:58:22 PM »
Thanks for the code. It will be very useful when I get to saved games.

I've now finished the inventory screen and fixed a few more bugs. There are a couple more bugs I know about that I'll take a look at this evening, and then after that it will be the menu system.

Offline lance.ewing

Re: C# AGI Interpreter
« Reply #42 on: January 27, 2017, 04:08:45 PM »
Would trying to port the Visual AGI Sound Editor to C# help with tackling AGI sound in C#?

I'm not sure actually. I'm familiar with the AGI sound format and with playing and converting the format. So its more around the way in which sound is produced in C# that I would need to learn.

Offline Kawa

Re: C# AGI Interpreter
« Reply #43 on: January 27, 2017, 04:49:21 PM »
C# has no handy-dandy built-in way of producing arbitrary sound, but there's various other methods. You could lowlevel some MIDI, for example: https://code.google.com/archive/p/midi-dot-net/

Offline Collector

Re: C# AGI Interpreter
« Reply #44 on: January 27, 2017, 11:00:15 PM »
I was looking at that library a few years ago when I was working on a project that also dealt with MIDI. I didn't look too far into it because I decided to just use PInvoke to do what I wanted.
KQII Remake Pic


SMF 2.0.11 | SMF © 2015, Simple Machines
Simple Audio Video Embedder

Page created in 0.13 seconds with 21 queries.