aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-05-12 13:51:10 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-05-12 13:51:10 +0300
commit315063b6d6e75d2279865e507cbe41add8b9f499 (patch)
tree7c637c78bef49ac72a4931e37e5397f749ee3bea
parent39cba7ccdfc9e71e8bff5df2f1a6ff28a2ae3556 (diff)
downloadMundus-315063b6d6e75d2279865e507cbe41add8b9f499.tar
Mundus-315063b6d6e75d2279865e507cbe41add8b9f499.tar.gz
Mundus-315063b6d6e75d2279865e507cbe41add8b9f499.zip
Finished refactoring of view layer (descided not to refactor game windows). Fair amount of stuff isn't documented because I think it is self explanatory.
-rw-r--r--Mundus/Program.cs25
-rw-r--r--Mundus/Views/Dialogs/ExitDialog.cs12
-rw-r--r--Mundus/Views/Windows/CraftingWindow.cs203
-rw-r--r--Mundus/Views/Windows/GameWindows/IGameWindow.cs19
-rw-r--r--Mundus/Views/Windows/LogWindow.cs104
-rw-r--r--Mundus/Views/Windows/MainWindow.cs37
-rw-r--r--Mundus/Views/Windows/MusicWindow.cs53
-rw-r--r--Mundus/Views/Windows/NewGameWindow.cs199
-rw-r--r--Mundus/Views/Windows/PauseWindow.cs53
-rw-r--r--Mundus/Views/Windows/SettingsWindow.cs36
-rw-r--r--Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs4
11 files changed, 461 insertions, 284 deletions
diff --git a/Mundus/Program.cs b/Mundus/Program.cs
index a9462a2..3d4530c 100644
--- a/Mundus/Program.cs
+++ b/Mundus/Program.cs
@@ -1,19 +1,20 @@
-using Gtk;
-using Mundus.Data;
-using Mundus.Data.Crafting;
-using Mundus.Data.Dialogues;
-using Mundus.Data.Superlayers.Mobs;
-using Mundus.Data.SuperLayers;
-using Mundus.Data.Windows;
+namespace Mundus
+{
+ using Gtk;
+ using Mundus.Data;
+ using Mundus.Data.Dialogues;
+ using Mundus.Data.Windows;
-namespace Mundus {
- public static class MainClass {
- public static bool runGame = true;
+ public static class MainClass
+ {
+ private static bool runGame = true;
- public static void Main(string[] args) {
+ public static void Main(string[] args)
+ {
DataBaseContexts.CreateInstances();
Application.Init();
- //All windows and dialogues that are used by user (instances) are saved and created in WindowInstances.cs
+
+ // All windows and dialogues that are used by user (instances) are saved and created in WindowInstances.cs
WI.CreateInstances();
DI.CreateInstances();
diff --git a/Mundus/Views/Dialogs/ExitDialog.cs b/Mundus/Views/Dialogs/ExitDialog.cs
index 3bbc69d..73aff2e 100644
--- a/Mundus/Views/Dialogs/ExitDialog.cs
+++ b/Mundus/Views/Dialogs/ExitDialog.cs
@@ -1,10 +1,14 @@
-namespace Mundus.Views.Dialogs {
- public partial class ExitDialog : Gtk.Dialog {
- public ExitDialog() {
+namespace Mundus.Views.Dialogs
+{
+ public partial class ExitDialog : Gtk.Dialog
+ {
+ public ExitDialog()
+ {
this.Build();
}
- protected void OnDeleteEvent(object o, Gtk.DeleteEventArgs args) {
+ protected void OnDeleteEvent(object o, Gtk.DeleteEventArgs args)
+ {
//To keep window instance (it is needed (stored in WindowInstances.cs) until Application.Quit)
args.RetVal = true;
}
diff --git a/Mundus/Views/Windows/CraftingWindow.cs b/Mundus/Views/Windows/CraftingWindow.cs
index 43ba6ff..149e33f 100644
--- a/Mundus/Views/Windows/CraftingWindow.cs
+++ b/Mundus/Views/Windows/CraftingWindow.cs
@@ -1,121 +1,162 @@
-using Gtk;
-using System;
-using Mundus.Service.Tiles.Crafting;
-using Mundus.Service.Tiles.Items;
-
-namespace Mundus.Views.Windows {
- public partial class CraftingWindow : Gtk.Window {
- public CraftingRecipe[] Recipes { get; set; }
+namespace Mundus.Views.Windows
+{
+ using System;
+ using Gtk;
+ using Mundus.Service.Tiles.Crafting;
+
+ public partial class CraftingWindow : Gtk.Window
+ {
+ /// <summary>
+ /// All the crafting recipes (gets set at Initialize())
+ /// </summary>
+ private CraftingRecipe[] recipes;
+
+ /// <summary>
+ /// Used to track which recipe should be displayed
+ /// </summary>
private int recipeIndex;
- public CraftingWindow() : base( Gtk.WindowType.Toplevel ) {
+ public CraftingWindow() : base(Gtk.WindowType.Toplevel)
+ {
this.Build();
}
- protected void OnDeleteEvent(object o, DeleteEventArgs args) {
+ /// <summary>
+ /// Resets visuals and prepares avalable recipes for current items in inventory
+ /// </summary>
+ public void Initialize()
+ {
+ this.Reset();
+
+ this.recipes = CraftingController.GetAvalableRecipes();
+ this.recipeIndex = 0;
+
+ this.PrintRecipe();
+ this.UpdateNextPrevBtns();
+ }
+
+ /// <summary>
+ /// Every time the window is closed, this gets called (hides the window)
+ /// </summary>
+ protected void OnDeleteEvent(object o, DeleteEventArgs args)
+ {
args.RetVal = true;
this.Hide();
}
/// <summary>
- /// Resets visuals and prepares avalable recipes for current items in inventory
+ /// Selects the previous avalable recipe and updates
/// </summary>
- public void Initialize() {
- Reset();
- this.Recipes = CraftingController.GetAvalableRecipes();
- recipeIndex = 0;
- PrintRecipe();
- UpdateNextPrevBtns();
+ protected void OnBtnPrevClicked(object sender, System.EventArgs e)
+ {
+ this.recipeIndex--;
+ this.PrintRecipe();
+
+ this.UpdateNextPrevBtns();
}
/// <summary>
- /// Sets information values for the currently selected recipe
+ /// Selects the following avalable recipe and updates
/// </summary>
- private void PrintRecipe() {
- if (Recipes.Length > 0) {
- ClearScreen();
- CraftingRecipe recipe = Recipes[recipeIndex];
- btnCraft.Sensitive = true;
+ protected void OnBtnNextClicked(object sender, System.EventArgs e)
+ {
+ this.recipeIndex++;
+ this.PrintRecipe();
- imgItem.SetFromStock(recipe.ResultItem, IconSize.Dnd);
- lblInfo.Text = recipe.ResultItem.ToString();
+ this.UpdateNextPrevBtns();
+ }
- lblC1.Text = recipe.Count1 + "";
- imgI1.SetFromStock(recipe.ReqItem1, IconSize.Dnd);
+ /// <summary>
+ /// Crafts the item (calls CraftingController and hides the window)
+ /// </summary>
+ protected void OnBtnCraftClicked(object sender, EventArgs e) {
+ CraftingController.CraftItemPlayer(this.recipes[this.recipeIndex]);
+ this.Hide();
+ }
- if (recipe.ReqItem2 != null) {
- lblC2.Text = recipe.Count2 + "";
- imgI2.SetFromStock(recipe.ReqItem2, IconSize.Dnd);
+ /// <summary>
+ /// Sets information values for the currently selected recipe
+ /// </summary>
+ private void PrintRecipe()
+ {
+ if (this.recipes.Length > 0)
+ {
+ this.ClearScreen();
+ CraftingRecipe recipe = this.recipes[this.recipeIndex];
+ this.btnCraft.Sensitive = true;
+
+ this.imgItem.SetFromStock(recipe.ResultItem, IconSize.Dnd);
+ this.lblInfo.Text = recipe.ResultItem.ToString();
+
+ this.lblC1.Text = recipe.Count1 + string.Empty;
+ this.imgI1.SetFromStock(recipe.ReqItem1, IconSize.Dnd);
+
+ if (recipe.ReqItem2 != null)
+ {
+ this.lblC2.Text = recipe.Count2 + string.Empty;
+ this.imgI2.SetFromStock(recipe.ReqItem2, IconSize.Dnd);
}
- if (recipe.ReqItem3 != null) {
- lblC3.Text = recipe.Count3 + "";
- imgI3.SetFromStock(recipe.ReqItem3, IconSize.Dnd);
+ if (recipe.ReqItem3 != null)
+ {
+ this.lblC3.Text = recipe.Count3 + string.Empty;
+ this.imgI3.SetFromStock(recipe.ReqItem3, IconSize.Dnd);
}
- if (recipe.ReqItem4 != null) {
- lblC4.Text = recipe.Count4 + "";
- imgI4.SetFromStock(recipe.ReqItem4, IconSize.Dnd);
+ if (recipe.ReqItem4 != null)
+ {
+ this.lblC4.Text = recipe.Count4 + string.Empty;
+ this.imgI4.SetFromStock(recipe.ReqItem4, IconSize.Dnd);
}
- if (recipe.ReqItem5 != null) {
- lblC5.Text = recipe.Count5 + "";
- imgI5.SetFromStock(recipe.ReqItem5, IconSize.Dnd);
+ if (recipe.ReqItem5 != null)
+ {
+ this.lblC5.Text = recipe.Count5 + string.Empty;
+ this.imgI5.SetFromStock(recipe.ReqItem5, IconSize.Dnd);
}
}
}
/// <summary>
- /// Selects the previous avalable recipe and updates
+ /// Updates the btnNext and btnPrev sensitivity
/// </summary>
- protected void OnBtnPrevClicked(object sender, System.EventArgs e) {
- recipeIndex--;
- PrintRecipe();
- UpdateNextPrevBtns();
+ private void UpdateNextPrevBtns()
+ {
+ this.btnNext.Sensitive = this.recipeIndex < this.recipes.Length - 1;
+ this.btnPrev.Sensitive = this.recipeIndex > 0;
}
+
/// <summary>
- /// Selects the following avalable recipe and updates
+ /// Sets default empty values for required items and their amounts
/// </summary>
- protected void OnBtnNextClicked(object sender, System.EventArgs e) {
- recipeIndex++;
- PrintRecipe();
- UpdateNextPrevBtns();
- }
-
- private void UpdateNextPrevBtns() {
- btnNext.Sensitive = recipeIndex < Recipes.Length - 1;
- btnPrev.Sensitive = recipeIndex > 0;
- }
-
- // Sets default empty values for required items and their amounts
- private void ClearScreen() {
- lblC1.Text = "0";
- lblC2.Text = "0";
- lblC3.Text = "0";
- lblC4.Text = "0";
- lblC5.Text = "0";
-
- imgI1.SetFromStock("empty", IconSize.Dnd);
- imgI2.SetFromStock("empty", IconSize.Dnd);
- imgI3.SetFromStock("empty", IconSize.Dnd);
- imgI4.SetFromStock("empty", IconSize.Dnd);
- imgI5.SetFromStock("empty", IconSize.Dnd);
+ private void ClearScreen()
+ {
+ this.lblC1.Text = "0";
+ this.lblC2.Text = "0";
+ this.lblC3.Text = "0";
+ this.lblC4.Text = "0";
+ this.lblC5.Text = "0";
+
+ this.imgI1.SetFromStock("empty", IconSize.Dnd);
+ this.imgI2.SetFromStock("empty", IconSize.Dnd);
+ this.imgI3.SetFromStock("empty", IconSize.Dnd);
+ this.imgI4.SetFromStock("empty", IconSize.Dnd);
+ this.imgI5.SetFromStock("empty", IconSize.Dnd);
}
- // Sets default empty values for the whole window
- private void Reset() {
- ClearScreen();
+ /// <summary>
+ /// Sets default empty values for the whole window
+ /// </summary>
+ private void Reset()
+ {
+ this.ClearScreen();
- imgItem.SetFromStock("empty", IconSize.Dnd);
- lblInfo.Text = null;
- btnPrev.Sensitive = false;
- btnNext.Sensitive = false;
- btnCraft.Sensitive = false;
- }
+ this.imgItem.SetFromStock("empty", IconSize.Dnd);
+ this.lblInfo.Text = null;
- protected void OnBtnCraftClicked(object sender, EventArgs e) {
- CraftingController.CraftItemPlayer(Recipes[recipeIndex]);
- this.Hide();
+ this.btnPrev.Sensitive = false;
+ this.btnNext.Sensitive = false;
+ this.btnCraft.Sensitive = false;
}
}
}
diff --git a/Mundus/Views/Windows/GameWindows/IGameWindow.cs b/Mundus/Views/Windows/GameWindows/IGameWindow.cs
index 95f8636..f5225c9 100644
--- a/Mundus/Views/Windows/GameWindows/IGameWindow.cs
+++ b/Mundus/Views/Windows/GameWindows/IGameWindow.cs
@@ -1,19 +1,28 @@
-using Mundus.Service.Tiles.Items;
+namespace Mundus.Views.Windows
+{
+ using Mundus.Service.Tiles.Items;
-namespace Mundus.Views.Windows {
- public interface IGameWindow {
+ public interface IGameWindow
+ {
int Size { get; }
- //Events that are generated from designer window
+ /// <summary>
+ /// Every time the window is closed, this gets called (hides the window)
+ /// </summary>
void OnDeleteEvent(object o, Gtk.DeleteEventArgs args);
+
void SetDefaults();
+
void PrintScreen();
+
void PrintMap();
+
void PrintMainMenu();
+
void PrintInventory();
+
void PrintSelectedItemInfo(ItemTile itemTile);
- //Stuff that are in Gtk.Window class
void Show();
}
}
diff --git a/Mundus/Views/Windows/LogWindow.cs b/Mundus/Views/Windows/LogWindow.cs
index 44f7f95..e6df1c5 100644
--- a/Mundus/Views/Windows/LogWindow.cs
+++ b/Mundus/Views/Windows/LogWindow.cs
@@ -1,59 +1,85 @@
-using System;
-using Mundus.Service;
+namespace Mundus.Views.Windows
+{
+ using System;
+ using Mundus.Service;
-namespace Mundus.Views.Windows {
- public partial class LogWindow : Gtk.Window {
- public LogWindow() :
- base(Gtk.WindowType.Toplevel) {
+ public partial class LogWindow : Gtk.Window
+ {
+ /// <summary>
+ /// Used for crolling up and down the log messages
+ /// </summary>
+ private int scroll = 0;
+
+ public LogWindow() : base(Gtk.WindowType.Toplevel)
+ {
this.Build();
+ }
+ /// <summary>
+ /// Prints all logs it can (starting from most recent) and updates the buttons
+ /// </summary>
+ public void Initialize()
+ {
+ this.PrintLogs();
+ this.UpdateButtons();
}
- public void Initialize() {
- PrintLogs();
- UpdateButtons();
+ /// <summary>
+ /// Prints the log messages
+ /// </summary>
+ public void PrintLogs()
+ {
+ for (int i = GameEventLogController.GetCount() - 1 - this.scroll, logIndex = 0; logIndex < 9; logIndex++, i--)
+ {
+ string msg = GameEventLogController.GetMessagage(i);
+
+ switch (logIndex)
+ {
+ case 0: this.lblLog1.Text = msg; break;
+ case 1: this.lblLog2.Text = msg; break;
+ case 2: this.lblLog3.Text = msg; break;
+ case 3: this.lblLog4.Text = msg; break;
+ case 4: this.lblLog5.Text = msg; break;
+ case 5: this.lblLog6.Text = msg; break;
+ case 6: this.lblLog7.Text = msg; break;
+ case 7: this.lblLog8.Text = msg; break;
+ case 8: this.lblLog9.Text = msg; break;
+ }
+ }
}
- protected void OnDeleteEvent(object o, Gtk.DeleteEventArgs args) {
+ /// <summary>
+ /// Every time the window is closed, this gets called (hides the window)
+ /// </summary>
+ protected void OnDeleteEvent(object o, Gtk.DeleteEventArgs args)
+ {
args.RetVal = true;
this.Hide();
}
- private int scroll = 0;
-
- public void PrintLogs() {
- for (int i = GameEventLogController.GetCount() - 1 - scroll, logIndex = 0; logIndex < 9; logIndex++, i--) {
- string msg = GameEventLogController.GetMessagage(i);
+ protected void OnBtnNewerClicked(object sender, EventArgs e)
+ {
+ this.scroll--;
+ this.PrintLogs();
- switch (logIndex) {
- case 0: lblLog1.Text = msg; break;
- case 1: lblLog2.Text = msg; break;
- case 2: lblLog3.Text = msg; break;
- case 3: lblLog4.Text = msg; break;
- case 4: lblLog5.Text = msg; break;
- case 5: lblLog6.Text = msg; break;
- case 6: lblLog7.Text = msg; break;
- case 7: lblLog8.Text = msg; break;
- case 8: lblLog9.Text = msg; break;
- }
- }
+ this.UpdateButtons();
}
- protected void OnBtnNewerClicked(object sender, EventArgs e) {
- scroll--;
- PrintLogs();
- UpdateButtons();
- }
+ protected void OnBtnOlderClicked(object sender, EventArgs e)
+ {
+ this.scroll++;
+ this.PrintLogs();
- protected void OnBtnOlderClicked(object sender, EventArgs e) {
- scroll++;
- PrintLogs();
- UpdateButtons();
+ this.UpdateButtons();
}
- private void UpdateButtons() {
- btnNewer.Sensitive = scroll > 0;
- btnOlder.Sensitive = scroll < GameEventLogController.GetCount() - 9;
+ /// <summary>
+ /// Updates the butNewer and btnOlder sensitivity
+ /// </summary>
+ private void UpdateButtons()
+ {
+ this.btnNewer.Sensitive = this.scroll > 0;
+ this.btnOlder.Sensitive = this.scroll < GameEventLogController.GetCount() - 9;
}
}
}
diff --git a/Mundus/Views/Windows/MainWindow.cs b/Mundus/Views/Windows/MainWindow.cs
index ae666be..fd09fa2 100644
--- a/Mundus/Views/Windows/MainWindow.cs
+++ b/Mundus/Views/Windows/MainWindow.cs
@@ -1,27 +1,38 @@
-using System;
-using Gtk;
-using Mundus.Service;
+namespace Mundus.Views.Windows
+{
+ using System;
+ using Gtk;
+ using Mundus.Service;
-namespace Mundus.Views.Windows {
- public partial class MainWindow : Gtk.Window {
- public MainWindow() : base( Gtk.WindowType.Toplevel ) {
+ public partial class MainWindow : Gtk.Window
+ {
+ public MainWindow() : base(Gtk.WindowType.Toplevel)
+ {
this.Build();
this.lblBuild.Text = Mundus.Data.Windows.WI.BuildName;
}
- private void OnDeleteEvent(object sender, DeleteEventArgs a) {
+ protected void OnBtnTutorialClicked(object sender, EventArgs e)
+ {
+ // TODO: impliment
+ }
+
+ /// <summary>
+ /// Every time the window is closed, this gets called (hides the window)
+ /// </summary>
+ private void OnDeleteEvent(object sender, DeleteEventArgs a)
+ {
Application.Quit();
}
- private void OnBtnNewGameClicked(object sender, EventArgs e) {
+ private void OnBtnNewGameClicked(object sender, EventArgs e)
+ {
WindowController.ShowNewGameWindow(this);
}
- private void OnBtnSettingsClicked(object sender, EventArgs e) {
+ private void OnBtnSettingsClicked(object sender, EventArgs e)
+ {
WindowController.ShowSettingsWindow(this);
}
-
- protected void OnBtnTutorialClicked(object sender, EventArgs e) {
- }
}
-}
+} \ No newline at end of file
diff --git a/Mundus/Views/Windows/MusicWindow.cs b/Mundus/Views/Windows/MusicWindow.cs
index 1dd8904..8e0ae54 100644
--- a/Mundus/Views/Windows/MusicWindow.cs
+++ b/Mundus/Views/Windows/MusicWindow.cs
@@ -1,42 +1,53 @@
-using System;
-using System.Media;
-using Gtk;
-
-namespace Mundus.Views.Windows {
- public partial class MusicWindow : Gtk.Window {
+namespace Mundus.Views.Windows
+{
+ using System;
+ using System.Media;
+ using Gtk;
+
+ public partial class MusicWindow : Gtk.Window
+ {
private SoundPlayer sp;
- public MusicWindow() : base( Gtk.WindowType.Toplevel ) {
+ public MusicWindow() : base( Gtk.WindowType.Toplevel )
+ {
this.Build();
- sp = new SoundPlayer();
+ this.sp = new SoundPlayer();
}
- protected void OnDeleteEvent(object o, DeleteEventArgs args) {
+ /// <summary>
+ /// Every time the window is closed, this gets called (hides the window)
+ /// </summary>
+ protected void OnDeleteEvent(object o, DeleteEventArgs args)
+ {
this.OnBtnBackClicked(this, null);
args.RetVal = true;
}
- protected void OnBtnBackClicked(object sender, EventArgs e) {
- //TODO: resume game loop
+ protected void OnBtnBackClicked(object sender, EventArgs e)
+ {
+ // TODO: resume game loop ?
this.Hide();
}
- protected void OnBtnPlayClicked(object sender, EventArgs e) {
- sp.SoundLocation = fcMusic.Filename;
- sp.Play();
+ protected void OnBtnPlayClicked(object sender, EventArgs e)
+ {
+ this.sp.SoundLocation = this.fcMusic.Filename;
+ this.sp.Play();
}
- protected void OnFcMusicSelectionChanged(object sender, EventArgs e) {
- lblPath.Text = fcMusic.Filename;
+ protected void OnFcMusicSelectionChanged(object sender, EventArgs e)
+ {
+ this.lblPath.Text = this.fcMusic.Filename;
}
- protected void OnBtnStopClicked(object sender, EventArgs e) {
- sp.Stop();
+ protected void OnBtnStopClicked(object sender, EventArgs e)
+ {
+ this.sp.Stop();
}
- protected void OnBtnNextClicked(object sender, EventArgs e) {
-
+ protected void OnBtnNextClicked(object sender, EventArgs e)
+ {
+ // TODO: impliment
}
-
}
}
diff --git a/Mundus/Views/Windows/NewGameWindow.cs b/Mundus/Views/Windows/NewGameWindow.cs
index d1e9bec..929f8d0 100644
--- a/Mundus/Views/Windows/NewGameWindow.cs
+++ b/Mundus/Views/Windows/NewGameWindow.cs
@@ -1,82 +1,135 @@
-using System;
-using Gtk;
-using Mundus.Service;
-
-namespace Mundus.Views.Windows {
- public partial class NewGameWindow : Gtk.Window {
- public NewGameWindow() : base( Gtk.WindowType.Toplevel ) {
+namespace Mundus.Views.Windows
+{
+ using System;
+ using Gtk;
+ using Mundus.Service;
+
+ public partial class NewGameWindow : Gtk.Window
+ {
+ public NewGameWindow() : base(Gtk.WindowType.Toplevel)
+ {
this.Build();
}
- private void OnDeleteEvent(object sender, DeleteEventArgs a) {
+ public void SetDefaults()
+ {
+ rbSurvival.Active = true;
+ rbEasy.Active = true;
+ rbSmall.Active = true;
+
+ this.SetMapSize();
+
+ rbMSmall.Sensitive = false;
+ rbMMedium.Sensitive = false;
+ rbMLarge.Sensitive = false;
+ }
+
+ /// <summary>
+ /// Every time the window is closed, this gets called (hides the window)
+ /// </summary>
+ protected void OnDeleteEvent(object sender, DeleteEventArgs a)
+ {
this.OnBtnBackClicked(this, null);
a.RetVal = true;
}
- private void OnBtnBackClicked(object sender, EventArgs e) {
+ protected void OnBtnBackClicked(object sender, EventArgs e)
+ {
WindowController.ShowMainWindow(this);
}
/// <summary>
- /// You can choose your Map size only in creative, it is predetermined by screen & inventory size in survival.
+ /// You can choose your Map size only in creative, it is predetermined by screen and inventory size in survival.
/// </summary>
+ protected void OnRbCreativeToggled(object sender, EventArgs e)
+ {
+ if (this.rbCreative.Active)
+ {
+ this.rbMSmall.Sensitive = true;
+ this.rbMMedium.Sensitive = true;
+ this.rbMLarge.Sensitive = true;
+ }
+ else
+ {
+ this.rbMSmall.Sensitive = false;
+ this.rbMMedium.Sensitive = false;
+ this.rbMLarge.Sensitive = false;
- private void OnRbCreativeToggled(object sender, EventArgs e) {
- if (rbCreative.Active) {
- rbMSmall.Sensitive = true;
- rbMMedium.Sensitive = true;
- rbMLarge.Sensitive = true;
- } else {
- rbMSmall.Sensitive = false;
- rbMMedium.Sensitive = false;
- rbMLarge.Sensitive = false;
- this.SetMapSize(); //in case (in creative) you selected screen & inventory and map sizes that are invalid in survival
+ this.SetMapSize(); // in case (in creative) you selected screen & inventory and map sizes that are invalid in survival
}
}
- public void SetDefaults() {
- rbSurvival.Active = true;
- rbEasy.Active = true;
- rbSmall.Active = true;
- SetMapSize();
+ protected void OnRbPeacefulToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("peaceful");
+ }
- rbMSmall.Sensitive = false;
- rbMMedium.Sensitive = false;
- rbMLarge.Sensitive = false;
+ protected void OnRbEasyToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("easy");
+ }
+
+ protected void OnRbNormalToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("normal");
+ }
+
+ protected void OnRbHardToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("hard");
+ }
+
+ protected void OnRbInsaneToggled(object sender, EventArgs e) {
+ GameGenerator.SetDifficulty("insane");
}
- //Automatically set map sizes from screen & inventory size only in survival mode
- private void OnRbSmallToggled(object sender, EventArgs e) {
- if (rbSurvival.Active) {
+ /* Automatically set map sizes from screen & inventory size only in survival mode */
+
+ protected void OnRbSmallToggled(object sender, EventArgs e)
+ {
+ if (rbSurvival.Active)
+ {
this.SetMapSize();
}
}
- private void OnRbMediumToggled(object sender, EventArgs e) {
- if (rbSurvival.Active) {
+
+ protected void OnRbMediumToggled(object sender, EventArgs e)
+ {
+ if (rbSurvival.Active)
+ {
this.SetMapSize();
}
}
- private void OnRbLargeToggled(object sender, EventArgs e) {
- if (rbSurvival.Active) {
+
+ protected void OnRbLargeToggled(object sender, EventArgs e)
+ {
+ if (rbSurvival.Active)
+ {
this.SetMapSize();
}
}
- //Sets map size from screen & inventory size
- private void SetMapSize() {
- if (rbSmall.Active) {
+ /// <summary>
+ /// Sets map size from screen and inventory size
+ /// </summary>
+ private void SetMapSize()
+ {
+ if (rbSmall.Active)
+ {
rbMLarge.Active = true;
}
- else if (rbMedium.Active) {
+ else if (rbMedium.Active)
+ {
rbMMedium.Active = true;
}
- else if (rbLarge.Active) {
+ else if (rbLarge.Active)
+ {
rbMSmall.Active = true;
}
}
- private void OnBtnGenerateClicked(object sender, EventArgs e) {
- //TODO: save settings somewhere
+ /// <summary>
+ /// Hides this screen, generates map and initializes the game window
+ /// </summary>
+ private void OnBtnGenerateClicked(object sender, EventArgs e)
+ {
+ // TODO: save settings somewhere
this.Hide();
this.ScreenInventorySetup();
@@ -84,62 +137,58 @@ namespace Mundus.Views.Windows {
GameGenerator.GameWindowInitialize();
}
- // Calls GameGenerator to generate the map depending on the selected map size button
- private void GenerateMap() {
- string size;
- if (rbMSmall.Active) {
+ /// <summary>
+ /// Calls GameGenerator to generate the map depending on the selected map size button
+ /// </summary>
+ private void GenerateMap()
+ {
+ string size = null;
+
+ if (rbMSmall.Active)
+ {
size = "small";
}
- else if (rbMMedium.Active) {
+ else if (rbMMedium.Active)
+ {
size = "medium";
}
- else if (rbMLarge.Active) {
+ else if (rbMLarge.Active)
+ {
size = "large";
}
- else {
+ else
+ {
throw new ArgumentException("No map size was selected");
}
+
GameGenerator.GenerateMap(size);
}
- // Does the inital steps that are required by all windows upon game generation
- private void ScreenInventorySetup() {
+ /// <summary>
+ /// Does the inital steps that are required by all windows upon game generation
+ /// </summary>
+ private void ScreenInventorySetup()
+ {
string gameWindow;
- if (rbSmall.Active) {
+ if (rbSmall.Active)
+ {
gameWindow = "small";
}
- else if (rbMedium.Active) {
+ else if (rbMedium.Active)
+ {
gameWindow = "medium";
}
- else if (rbLarge.Active) {
+ else if (rbLarge.Active)
+ {
gameWindow = "large";
}
- else {
+ else
+ {
throw new ArgumentException("No screen & inventory size was selected");
}
GameGenerator.GameWindowSizeSetup(gameWindow);
}
-
- protected void OnRbPeacefulToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("peaceful");
- }
-
- protected void OnRbEasyToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("easy");
- }
-
- protected void OnRbNormalToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("normal");
- }
-
- protected void OnRbHardToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("hard");
- }
-
- protected void OnRbInsaneToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("insane");
- }
}
}
diff --git a/Mundus/Views/Windows/PauseWindow.cs b/Mundus/Views/Windows/PauseWindow.cs
index b67e27c..45067be 100644
--- a/Mundus/Views/Windows/PauseWindow.cs
+++ b/Mundus/Views/Windows/PauseWindow.cs
@@ -1,37 +1,60 @@
-using System;
-using Gtk;
-using Mundus.Service;
+namespace Mundus.Views.Windows
+{
+ using System;
+ using Gtk;
+ using Mundus.Service;
-namespace Mundus.Views.Windows {
- public partial class PauseWindow : Gtk.Window {
- public IGameWindow GameWindow { get; set; }
-
- public PauseWindow() : base( Gtk.WindowType.Toplevel ) {
+ public partial class PauseWindow : Gtk.Window
+ {
+ public PauseWindow() : base(Gtk.WindowType.Toplevel)
+ {
this.Build();
this.lblBuild.Text = Mundus.Data.Windows.WI.BuildName;
}
- protected void OnDeleteEvent(object o, Gtk.DeleteEventArgs args) {
+ /// <summary>
+ /// Gets or sets the game window that opened the pause window (see OnBtnExitClicked)
+ /// </summary>
+ public IGameWindow GameWindow { get; set; }
+
+ /// <summary>
+ /// Every time the window is closed, this gets called (hides the window)
+ /// </summary>
+ protected void OnDeleteEvent(object o, Gtk.DeleteEventArgs args)
+ {
WindowController.PauseWindowVisible = false;
this.Hide();
args.RetVal = true;
}
- protected void OnBtnSettingsClicked(object sender, EventArgs e) {
+ protected void OnBtnSettingsClicked(object sender, EventArgs e)
+ {
WindowController.ShowSettingsWindow(this);
}
- protected void OnBtnSaveClicked(object sender, EventArgs e) {
- //TODO: call saving code
+ /// <summary>
+ /// Saves the game state (map and inventories) and closes the pause window
+ /// </summary>
+ protected void OnBtnSaveClicked(object sender, EventArgs e)
+ {
+ // TODO: call saving code
this.OnDeleteEvent(this, new DeleteEventArgs());
}
- protected void OnBtnSaveExitClicked(object sender, EventArgs e) {
- //TODO: call saving code
+ /// <summary>
+ /// Saves the game, closes the window and also closes the window that opened it
+ /// </summary>
+ protected void OnBtnSaveExitClicked(object sender, EventArgs e)
+ {
+ this.OnBtnSaveClicked(null, null);
this.GameWindow.OnDeleteEvent(this, new DeleteEventArgs());
}
- protected void OnBtnExitClicked(object sender, EventArgs e) {
+ /// <summary>
+ /// Closes the window and also closes the window that opened it
+ /// </summary>
+ protected void OnBtnExitClicked(object sender, EventArgs e)
+ {
this.GameWindow.OnDeleteEvent(this, new DeleteEventArgs());
}
}
diff --git a/Mundus/Views/Windows/SettingsWindow.cs b/Mundus/Views/Windows/SettingsWindow.cs
index 84b1b37..60ab6b3 100644
--- a/Mundus/Views/Windows/SettingsWindow.cs
+++ b/Mundus/Views/Windows/SettingsWindow.cs
@@ -1,25 +1,31 @@
-using System;
-using Gtk;
+namespace Mundus.Views.Windows
+{
+ using Gtk;
-namespace Mundus.Views.Windows {
- public partial class SettingsWindow : Gtk.Window {
- //This is used to show the sender (the window that showed this one) when you close this window
- public Window Sender { get; private set; }
-
- public SettingsWindow() : base( Gtk.WindowType.Toplevel ) {
+ public partial class SettingsWindow : Gtk.Window
+ {
+ public SettingsWindow() : base(Gtk.WindowType.Toplevel)
+ {
this.Build();
}
- private void OnDeleteEvent(object sender, DeleteEventArgs a) {
- //Return to the sender window (and dont destroy the settings window instance)
- this.Hide();
- Sender.Show();
- a.RetVal = true;
- }
+ /// <summary>
+ /// This is used to show the sender (the window that opened this one) when you close this window
+ /// </summary>
+ public Window Sender { get; private set; }
- public void Show(Window sender) {
+ public void Show(Window sender)
+ {
this.Show();
this.Sender = sender;
}
+
+ protected void OnDeleteEvent(object sender, DeleteEventArgs a)
+ {
+ // Return to the sender window (and dont destroy the settings window instance)
+ this.Hide();
+ this.Sender.Show();
+ a.RetVal = true;
+ }
}
}
diff --git a/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs b/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs
index 2ea610e..0bbc355 100644
--- a/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs
+++ b/Mundus/gtk-gui/Mundus.Views.Windows.NewGameWindow.cs
@@ -247,7 +247,6 @@ namespace Mundus.Views.Windows
this.rbCreative.Sensitive = false;
this.rbCreative.CanFocus = true;
this.rbCreative.Name = "rbCreative";
- this.rbCreative.Active = true;
this.rbCreative.DrawIndicator = true;
this.rbCreative.UseUnderline = true;
this.rbCreative.Group = new global::GLib.SList(global::System.IntPtr.Zero);
@@ -264,7 +263,6 @@ namespace Mundus.Views.Windows
this.rbEasy.WidthRequest = 90;
this.rbEasy.CanFocus = true;
this.rbEasy.Name = "rbEasy";
- this.rbEasy.Active = true;
this.rbEasy.DrawIndicator = true;
this.rbEasy.UseUnderline = true;
this.rbEasy.Group = new global::GLib.SList(global::System.IntPtr.Zero);
@@ -313,7 +311,6 @@ namespace Mundus.Views.Windows
this.rbLarge.WidthRequest = 90;
this.rbLarge.CanFocus = true;
this.rbLarge.Name = "rbLarge";
- this.rbLarge.Active = true;
this.rbLarge.DrawIndicator = true;
this.rbLarge.UseUnderline = true;
this.rbLarge.Group = new global::GLib.SList(global::System.IntPtr.Zero);
@@ -345,7 +342,6 @@ namespace Mundus.Views.Windows
this.rbMLarge = new global::Gtk.RadioButton("Large");
this.rbMLarge.CanFocus = true;
this.rbMLarge.Name = "rbMLarge";
- this.rbMLarge.Active = true;
this.rbMLarge.DrawIndicator = true;
this.rbMLarge.UseUnderline = true;
this.rbMLarge.Group = new global::GLib.SList(global::System.IntPtr.Zero);