Skip to content

Commit 99c0a7c

Browse files
author
Hamish
committed
Final commit for Version 0.03
1 parent 270b88d commit 99c0a7c

7 files changed

+133
-63
lines changed

src/koside/App.config

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
<value />
1515
</setting>
1616
<setting name="DarkMode" serializeAs="String">
17-
<value>True</value>
17+
<value>False</value>
1818
</setting>
1919
<setting name="FirstRun" serializeAs="String">
2020
<value>True</value>
2121
</setting>
22+
<setting name="OS" serializeAs="String">
23+
<value />
24+
</setting>
2225
</koside.Properties.Settings>
2326
</userSettings>
2427
</configuration>

src/koside/Form1.Designer.cs

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/koside/Form1.cs

+52-44
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@ private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
158158
saveFileDialog1.Filter = "kOS Script Files|*.ks";
159159
saveFileDialog1.FilterIndex = 2;
160160
saveFileDialog1.RestoreDirectory = true;
161-
saveFileDialog1.InitialDirectory = Properties.Settings.Default.KSPLoc + @"\Ships\Script\";
162-
161+
if (Properties.Settings.Default.OS == "Windows")
162+
saveFileDialog1.InitialDirectory = Properties.Settings.Default.KSPLoc + @"\Ships\Script\";
163+
else if (Properties.Settings.Default.OS == "Linux")
164+
saveFileDialog1.InitialDirectory = @"steam/steamapps/common/Kerbal Space Program/Ships/Scripts/";
163165
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
164166
{
165167
System.IO.File.WriteAllText(saveFileDialog1.FileName.ToString(), body.Text);
@@ -323,7 +325,7 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
323325

324326
private void exportToKSPToolStripMenuItem_Click(object sender, EventArgs e)
325327
{
326-
if (tabControl1.SelectedTab.Controls.ContainsKey("body"))
328+
/* if (tabControl1.SelectedTab.Controls.ContainsKey("body"))
327329
{
328330
Scintilla body = (Scintilla)tabControl1.SelectedTab.Controls["body"];
329331
//Export to KSP scripts folder.
@@ -335,7 +337,8 @@ private void exportToKSPToolStripMenuItem_Click(object sender, EventArgs e)
335337
string location = Properties.Settings.Default.KSPLoc + @"\Ships\Script\" + file;
336338
System.IO.File.WriteAllText(location, body.Text);
337339
}
338-
}
340+
}*/
341+
MessageBox.Show("Feautre inentionally disabled. Please use save as instead");
339342
}
340343

341344
private void licenceToolStripMenuItem_Click(object sender, EventArgs e)
@@ -377,11 +380,6 @@ private void scintilla_CharAdded(object sender, CharAddedEventArgs e)
377380
}
378381
}
379382

380-
private void helpToolStripMenuItem1_Click(object sender, EventArgs e)
381-
{
382-
MessageBox.Show("Hey look, Another unimplemented feature");
383-
}
384-
385383
private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e)
386384
{
387385
Version newVersion = null;
@@ -515,6 +513,38 @@ private void RedoButton_Click(object sender, EventArgs e)
515513
Redo();
516514
}
517515

516+
private void wholeScriptToolStripMenuItem_Click(object sender, EventArgs e)
517+
{
518+
int i = tabControl1.SelectedIndex;
519+
520+
if (tabControl1.SelectedTab.Controls.ContainsKey("body"))
521+
{
522+
//Save to same file as opened from
523+
Scintilla body = (Scintilla)tabControl1.SelectedTab.Controls["body"];
524+
string s = body.Text;
525+
s = " " + s;
526+
s = s.Replace(System.Environment.NewLine, " \r\n ");
527+
Clipboard.SetText(s);
528+
MessageBox.Show("Scipt is now in your clipboard");
529+
}
530+
}
531+
532+
private void selectionToolStripMenuItem_Click(object sender, EventArgs e)
533+
{
534+
int i = tabControl1.SelectedIndex;
535+
536+
if (tabControl1.SelectedTab.Controls.ContainsKey("body"))
537+
{
538+
//Save to same file as opened from
539+
Scintilla body = (Scintilla)tabControl1.SelectedTab.Controls["body"];
540+
string s = body.SelectedText;
541+
s = " " + s;
542+
s = s.Replace(System.Environment.NewLine, " \r\n ");
543+
Clipboard.SetText(s);
544+
MessageBox.Show("Selection is now in your clipboard");
545+
}
546+
}
547+
518548
private void New()
519549
{
520550
try
@@ -634,7 +664,10 @@ private void SaveAll()
634664
saveFileDialog1.Filter = "kOS Script Files|*.ks";
635665
saveFileDialog1.FilterIndex = 2;
636666
saveFileDialog1.RestoreDirectory = true;
637-
saveFileDialog1.InitialDirectory = Properties.Settings.Default.KSPLoc + @"\Ships\Script\";
667+
if (Properties.Settings.Default.OS == "Windows")
668+
saveFileDialog1.InitialDirectory = Properties.Settings.Default.KSPLoc + @"\Ships\Script\";
669+
else if (Properties.Settings.Default.OS == "Linux")
670+
saveFileDialog1.InitialDirectory = @"steam/steamapps/common/Kerbal Space Program/Ships/Scripts/";
638671

639672
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
640673
{
@@ -658,7 +691,10 @@ private void Open()
658691
OpenFileDialog theDialog = new OpenFileDialog();
659692
theDialog.Title = "Open Script";
660693
theDialog.Filter = "kOS Scripts|*.ks";
661-
theDialog.InitialDirectory = Properties.Settings.Default.KSPLoc + @"\Ships\Script\";
694+
if (Properties.Settings.Default.OS == "Windows")
695+
theDialog.InitialDirectory = Properties.Settings.Default.KSPLoc + @"\Ships\Script\";
696+
else if (Properties.Settings.Default.OS == "Linux")
697+
theDialog.InitialDirectory = @"steam/steamapps/common/Kerbal Space Program/Ships/Scripts/";
662698
if (theDialog.ShowDialog() == DialogResult.OK)
663699
{
664700
int i = tabControl1.TabCount - 1;
@@ -685,7 +721,10 @@ private void Open()
685721
OpenFileDialog theDialogi = new OpenFileDialog();
686722
theDialogi.Title = "Open Script";
687723
theDialogi.Filter = "kOS Scripts|*.ks";
688-
theDialogi.InitialDirectory = Properties.Settings.Default.KSPLoc + @"\Ships\Script\";
724+
if (Properties.Settings.Default.OS == "Windows")
725+
theDialogi.InitialDirectory = Properties.Settings.Default.KSPLoc + @"\Ships\Script\";
726+
else if (Properties.Settings.Default.OS == "Linux")
727+
theDialogi.InitialDirectory = @"steam/steamapps/common/Kerbal Space Program/Ships/Scripts/";
689728
if (theDialogi.ShowDialog() == DialogResult.OK)
690729
{
691730
int i = tabControl1.TabCount - 1;
@@ -706,7 +745,7 @@ private void Open()
706745
tabControl1.Refresh();
707746
}
708747

709-
public void addTab()
748+
private void addTab()
710749
{
711750

712751
TabPage tab = new TabPage("Untitled X");
@@ -834,37 +873,6 @@ private void HighlightWord(string text)
834873
}
835874
}
836875

837-
private void wholeScriptToolStripMenuItem_Click(object sender, EventArgs e)
838-
{
839-
int i = tabControl1.SelectedIndex;
840-
841-
if (tabControl1.SelectedTab.Controls.ContainsKey("body"))
842-
{
843-
//Save to same file as opened from
844-
Scintilla body = (Scintilla)tabControl1.SelectedTab.Controls["body"];
845-
string s = body.Text;
846-
s = " " + s;
847-
s = s.Replace(System.Environment.NewLine, " \r\n ");
848-
Clipboard.SetText(s);
849-
MessageBox.Show("Scipt is now in your clipboard");
850-
}
851-
}
852-
853-
private void selectionToolStripMenuItem_Click(object sender, EventArgs e)
854-
{
855-
int i = tabControl1.SelectedIndex;
856-
857-
if (tabControl1.SelectedTab.Controls.ContainsKey("body"))
858-
{
859-
//Save to same file as opened from
860-
Scintilla body = (Scintilla)tabControl1.SelectedTab.Controls["body"];
861-
string s = body.SelectedText;
862-
s = " " + s;
863-
s = s.Replace(System.Environment.NewLine, " \r\n ");
864-
Clipboard.SetText(s);
865-
MessageBox.Show("Selection is now in your clipboard");
866-
}
867-
}
868876
}
869877

870878
public class MySR : ToolStripSystemRenderer

src/koside/Program.cs

+58-13
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,71 @@ static void Main()
1919
Application.SetCompatibleTextRenderingDefault(false);
2020
if(Properties.Settings.Default.FirstRun == true)
2121
{
22-
try
22+
var drives = System.IO.DriveInfo.GetDrives();
23+
if (drives.Where(data => data.Name == "Z:\\").Count() == 1)
2324
{
24-
RegistryKey OurKey = Registry.LocalMachine;
25-
OurKey = OurKey.OpenSubKey(@"SOFTWARE\WOW6432Node\Valve", false);
26-
RegistryKey key = OurKey.OpenSubKey("Steam");
27-
string path = key.GetValue("InstallPath").ToString();
28-
DialogResult dialogResult = MessageBox.Show("Because this is the first time you have used Kode, We will see if we can find where Steam is installed. Is this correct?\n" + path, "Is this corrent?", MessageBoxButtons.YesNo);
29-
if (dialogResult == DialogResult.Yes)
25+
RegistryKey OurKey = Registry.CurrentUser;
26+
OurKey = OurKey.OpenSubKey(@"SOFTWARE\", false);
27+
RegistryKey key = OurKey.OpenSubKey("Wine");
28+
if (key != null)
3029
{
31-
Properties.Settings.Default.KSPLoc = path + @"\steamapps\common\Kerbal Space Program";
30+
Properties.Settings.Default.KSPLoc = "This doesnt matter on Linux";
31+
Properties.Settings.Default.OS = "Linux";
3232
}
3333
else
3434
{
35-
MessageBox.Show("Whoops. Please visit Settings to fix it :)");
35+
try
36+
{
37+
RegistryKey OurKeyi = Registry.LocalMachine;
38+
OurKeyi = OurKeyi.OpenSubKey(@"SOFTWARE\WOW6432Node\Valve", false);
39+
RegistryKey keyi = OurKeyi.OpenSubKey("Steam");
40+
string path = keyi.GetValue("InstallPath").ToString();
41+
DialogResult dialogResult = MessageBox.Show("Because this is the first time you have used Kode, We will see if we can find where Steam is installed. Is this correct?\n" + path, "Is this corrent?", MessageBoxButtons.YesNo);
42+
if (dialogResult == DialogResult.Yes)
43+
{
44+
Properties.Settings.Default.KSPLoc = path + @"\steamapps\common\Kerbal Space Program";
45+
}
46+
else
47+
{
48+
MessageBox.Show("Whoops. Please visit Settings to fix it :)");
49+
}
50+
Properties.Settings.Default.FirstRun = false;
51+
Properties.Settings.Default.OS = "Windows";
52+
}
53+
catch
54+
{
55+
MessageBox.Show("Hello! There seems to be a problem finding where Steam is installed. Please go to settings to manually add. Error: 1");
56+
Properties.Settings.Default.FirstRun = false;
57+
Properties.Settings.Default.OS = "Windows";
58+
}
3659
}
37-
Properties.Settings.Default.FirstRun = false;
38-
}catch
60+
}
61+
else
3962
{
40-
MessageBox.Show("Hello! There seems to be a problem finding where Steam is installed. Please go to settings to manually add. Error: 1");
41-
Properties.Settings.Default.FirstRun = false;
63+
try
64+
{
65+
RegistryKey OurKey = Registry.LocalMachine;
66+
OurKey = OurKey.OpenSubKey(@"SOFTWARE\WOW6432Node\Valve", false);
67+
RegistryKey key = OurKey.OpenSubKey("Steam");
68+
string path = key.GetValue("InstallPath").ToString();
69+
DialogResult dialogResult = MessageBox.Show("Because this is the first time you have used Kode, We will see if we can find where Steam is installed. Is this correct?\n" + path, "Is this corrent?", MessageBoxButtons.YesNo);
70+
if (dialogResult == DialogResult.Yes)
71+
{
72+
Properties.Settings.Default.KSPLoc = path + @"\steamapps\common\Kerbal Space Program";
73+
}
74+
else
75+
{
76+
MessageBox.Show("Whoops. Please visit Settings to fix it :)");
77+
}
78+
Properties.Settings.Default.FirstRun = false;
79+
Properties.Settings.Default.OS = "Windows";
80+
}
81+
catch
82+
{
83+
MessageBox.Show("Hello! There seems to be a problem finding where Steam is installed. Please go to settings to manually add. Error: 1");
84+
Properties.Settings.Default.FirstRun = false;
85+
Properties.Settings.Default.OS = "Windows";
86+
}
4287
}
4388
}
4489
Application.Run(new Form1());

src/koside/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.2.1")]
36-
[assembly: AssemblyFileVersion("0.2.1")]
35+
[assembly: AssemblyVersion("0.3.0")]
36+
[assembly: AssemblyFileVersion("0.3.0")]
3737

src/koside/Properties/Settings.Designer.cs

+13-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/koside/Properties/Settings.settings

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
<Value Profile="(Default)" />
77
</Setting>
88
<Setting Name="DarkMode" Type="System.Boolean" Scope="User">
9-
<Value Profile="(Default)">True</Value>
9+
<Value Profile="(Default)">False</Value>
1010
</Setting>
1111
<Setting Name="FirstRun" Type="System.Boolean" Scope="User">
1212
<Value Profile="(Default)">True</Value>
1313
</Setting>
14+
<Setting Name="OS" Type="System.String" Scope="User">
15+
<Value Profile="(Default)" />
16+
</Setting>
1417
</Settings>
1518
</SettingsFile>

0 commit comments

Comments
 (0)