Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
embedded levels and database in assembly and then extract at first ru…
Browse files Browse the repository at this point in the history
…n to proper users %appdata% folder. (Issue: 3)

update setup for 1.0.1 release.
  • Loading branch information
root@d9ping.nl committed Mar 27, 2012
1 parent 1777f87 commit 82a1f22
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 25 deletions.
9 changes: 3 additions & 6 deletions Frogger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,14 @@
<None Include="Resources\texture_water.jpg" />
</ItemGroup>
<ItemGroup>
<Content Include="bin\Debug\levels\basic1.lvl" />
<Content Include="bin\Debug\levels\basic2.lvl" />
<Content Include="bin\Debug\levels\basic3.lvl" />
<None Include="bin\Debug\highscores.mdb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="bin\Debug\sounds\beep.wav" />
<Content Include="bin\Debug\sounds\frog_made_it.wav" />
<Content Include="bin\Debug\sounds\punch.wav" />
<Content Include="bin\Debug\sounds\sink.wav" />
<Content Include="icon_frog.ico" />
<None Include="bin\Debug\levels\coolroad.lvl" />
<None Include="bin\Debug\levels\highway.lvl" />
<None Include="bin\Debug\levels\sea.lvl" />
<None Include="Resources\car_green_east.png" />
<None Include="Resources\car_green_west.png" />
<Content Include="Resources\car_grey_east.png" />
Expand Down
53 changes: 50 additions & 3 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,54 @@ static public string GetSoundDir()
/// Get the folder with the levels
/// </summary>
/// <returns></returns>
static public string GetLevelFolder()
public static string GetLevelFolder()
{
const string LEVELFOLDERNAME = "levels";
string lvldir = Path.Combine(GetAppDataFolder(), LEVELFOLDERNAME);

if (!Directory.Exists(lvldir))
{
Directory.CreateDirectory(lvldir);
//throw new Exception("Cannot find level directory.");

ExtractFile(lvldir, "basic1.lvl", Frogger.Properties.Resources.lvl_basic1);
ExtractFile(lvldir, "basic2.lvl", Frogger.Properties.Resources.lvl_basic2);
ExtractFile(lvldir, "basic3.lvl", Frogger.Properties.Resources.lvl_basic3);
ExtractFile(lvldir, "coolroad.lvl", Frogger.Properties.Resources.lvl_coolroad);
ExtractFile(lvldir, "highway.lvl", Frogger.Properties.Resources.lvl_highway);
ExtractFile(lvldir, "sea.lvl", Frogger.Properties.Resources.lvl_sea);
}

return lvldir;
}

/// <summary>
/// Extract level file
/// </summary>
/// <param name="lvldir"></param>
/// <param name="filename"></param>
/// <param name="lvlresources"></param>
private static void ExtractFile(string folder, string filename, byte[] resource)
{
string filepath = Path.Combine(folder, filename);
if (!File.Exists(filepath))
{
System.IO.FileStream writer = null;
try
{
writer = new System.IO.FileStream(filepath, System.IO.FileMode.Create, System.IO.FileAccess.Write);
writer.Write(resource, 0, resource.Length);
writer.Flush();
}
finally
{
if (writer != null)
{
writer.Close();
}
}
}
}

/// <summary>
/// Gets the application data folder of froggerreloaded.
/// </summary>
Expand All @@ -153,13 +187,26 @@ static public string GetAppDataFolder()
{
const string APPDATAFOLDERNAME = "froggerreloaded";
#if windows
// todo
string appdatadir = Path.Combine(System.Environment.GetEnvironmentVariable("APPDATA"), APPDATAFOLDERNAME);
if (!String.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("ProgramData")))
{
appdatadir = Path.Combine(System.Environment.GetEnvironmentVariable("APPDATA"), APPDATAFOLDERNAME);
}
#elif linux
string lvldir = Path.Combine(System.Environment.GetEnvironmentVariable("HOME"), "."+APPDATAFOLDERNAME);;
#endif
if (!Directory.Exists(appdatadir))
{
Directory.CreateDirectory(appdatadir);
try
{
Directory.CreateDirectory(appdatadir);

ExtractFile(appdatadir, "highscores.mdb", Frogger.Properties.Resources.highscores);
}
catch (UnauthorizedAccessException)
{
}
}

return appdatadir;
Expand Down
21 changes: 21 additions & 0 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,25 @@
<data name="selecteditem" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\selecteditem.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="lvl_basic1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\bin\Debug\levels\basic1.lvl;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="lvl_basic2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\bin\Debug\levels\basic2.lvl;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="lvl_basic3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\bin\Debug\levels\basic3.lvl;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="lvl_coolroad" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\bin\Debug\levels\coolroad.lvl;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="lvl_highway" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\bin\Debug\levels\highway.lvl;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="lvl_sea" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\bin\Debug\levels\sea.lvl;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="highscores" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\bin\Debug\highscores.mdb;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
51 changes: 50 additions & 1 deletion Properties/Resources1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@
&lt;ConnectionString&gt;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\highscores.accdb&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.OleDb&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue>
<Value Profile="(Default)">Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\highscores.accdb</Value>
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionstring xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;ConnectionString&gt;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\highscores.accdb&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.OleDb&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</Value>
</Setting>
<Setting Name="highscoresConnectionString1" Type="(Connection string)" Scope="Application">
<DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;ConnectionString&gt;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\bin\Debug\highscores.mdb;Persist Security Info=True&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.OleDb&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue>
<Value Profile="(Default)">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\bin\Debug\highscores.mdb;Persist Security Info=True</Value>
</Setting>
</Settings>
</SettingsFile>
19 changes: 17 additions & 2 deletions Properties/Settings1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<section name="Frogger.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
<add name="Frogger.Properties.Settings.highscoresConnectionString"
connectionString="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&#xD;&#xA;&lt;SerializableConnectionstring xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA; &lt;ConnectionString&gt;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\highscores.accdb&lt;/ConnectionString&gt;&#xD;&#xA; &lt;ProviderName&gt;System.Data.OleDb&lt;/ProviderName&gt;&#xD;&#xA;&lt;/SerializableConnectionString&gt;"
providerName="" />
<add name="Frogger.Properties.Settings.highscoresConnectionString1"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\bin\Debug\highscores.mdb;Persist Security Info=True"
providerName="System.Data.OleDb" />
</connectionStrings>
<startup><supportedRuntime version="v2.0.50727"/></startup><userSettings>
<Frogger.Properties.Settings>
<setting name="fullscreen" serializeAs="String">
Expand Down
Binary file modified bin/Debug/Frogger.exe
Binary file not shown.
8 changes: 8 additions & 0 deletions bin/Debug/Frogger.exe.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<section name="Frogger.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
<add name="Frogger.Properties.Settings.highscoresConnectionString"
connectionString="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&#xD;&#xA;&lt;SerializableConnectionstring xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;&gt;&#xD;&#xA; &lt;ConnectionString&gt;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\highscores.accdb&lt;/ConnectionString&gt;&#xD;&#xA; &lt;ProviderName&gt;System.Data.OleDb&lt;/ProviderName&gt;&#xD;&#xA;&lt;/SerializableConnectionString&gt;"
providerName="" />
<add name="Frogger.Properties.Settings.highscoresConnectionString1"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\bin\Debug\highscores.mdb;Persist Security Info=True"
providerName="System.Data.OleDb" />
</connectionStrings>
<startup><supportedRuntime version="v2.0.50727"/></startup><userSettings>
<Frogger.Properties.Settings>
<setting name="fullscreen" serializeAs="String">
Expand Down
Binary file modified bin/Debug/Frogger.pdb
Binary file not shown.
Binary file modified bin/Debug/highscores.mdb
Binary file not shown.
20 changes: 9 additions & 11 deletions bin/setup/create_setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ Source: ..\Debug\sounds\frog_made_it.wav; DestDir: {app}\sounds\; Flags: ignorev
Source: ..\Debug\sounds\punch.wav; DestDir: {app}\sounds\; Flags: ignoreversion
Source: ..\Debug\sounds\sink.wav; DestDir: {app}\sounds\; Flags: ignoreversion
Source: ..\..\Resources\Flubber.ttf; DestDir: {fonts}; FontInstall: Flubber; Flags: onlyifdoesntexist uninsneveruninstall

Source: ..\Debug\highscores.mdb; DestDir: {userappdata}\froggerreloaded\; Flags: ignoreversion
Source: ..\Debug\levels\basic1.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
Source: ..\Debug\levels\basic2.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
Source: ..\Debug\levels\basic3.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
Source: ..\Debug\levels\coolroad.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
Source: ..\Debug\levels\highway.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
Source: ..\Debug\levels\sea.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
; currently embedded in Frogger.exe executable and then extracted to %appdata%\froggerreloaded\ so it work for every user on the system.
;Source: ..\Debug\highscores.mdb; DestDir: {userappdata}\froggerreloaded\; Flags: ignoreversion
;Source: ..\Debug\levels\basic1.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
;Source: ..\Debug\levels\basic2.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
;Source: ..\Debug\levels\basic3.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
;Source: ..\Debug\levels\coolroad.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
;Source: ..\Debug\levels\highway.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion
;Source: ..\Debug\levels\sea.lvl; DestDir: {userappdata}\froggerreloaded\levels\; Flags: ignoreversion

[Icons]
Name: {group}\Frogger Reloaded; Filename: {app}\Frogger.exe
Expand Down Expand Up @@ -98,9 +98,7 @@ begin
else
begin
Result:=false;
ShellExec('open',
'http://download.microsoft.com/download/5/6/7/567758a3-759e-473e-bf8f-52154438565a/dotnetfx.exe',
'','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
ShellExec('open','http://download.microsoft.com/download/5/6/7/567758a3-759e-473e-bf8f-52154438565a/dotnetfx.exe','','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
end;
end;
end;
Expand Down
2 changes: 1 addition & 1 deletion make_archive.bat
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ echo 7-zip(7z.exe) should be installed in: %path7z%
pause
IF NOT EXIST %path7z% GOTO NO7ZDIR

%path7z% a -tzip "%cd%\bin\source\src_froggerreloaded_v%VERSION%.zip" -r %cd%\*.cs %cd%\*.resx %cd%\*.config %cd%\*.sln %cd%\*.csproj %cd%\*.eqconfig %cd%\*.png %cd%\*.jpg %cd%\*.ico %cd%\*.bat %cd%\*.xsd %cd%\*.manifest %cd%\*.iss %cd%\*.settings %cd%\*.csproj.user %cd%\*.in
%path7z% a -tzip "%cd%\bin\source\src_froggerreloaded_v%VERSION%.zip" -r %cd%\*.cs %cd%\*.resx %cd%\*.config %cd%\*.sln %cd%\*.csproj %cd%\*.eqconfig %cd%\*.png %cd%\*.jpg %cd%\*.ico %cd%\*.bat %cd%\*.xsd %cd%\*.iss %cd%\*.settings %cd%\*.csproj.user %cd%\*.in

echo done.
pause
Expand Down

0 comments on commit 82a1f22

Please sign in to comment.