blob: 61999d7e13604d0b4dcb4f6f5929491026517850 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
using System;
using Gtk;
using Mundus.Service;
namespace Mundus.Views.Windows {
public partial class NewGameWindow : Gtk.Window {
public NewGameWindow() : base( Gtk.WindowType.Toplevel ) {
this.Build();
}
private void OnDeleteEvent(object sender, DeleteEventArgs a) {
this.OnBtnBackClicked(this, null);
a.RetVal = true;
}
private 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.
/// </summary>
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
}
}
public void SetDefaults() {
rbSurvival.Active = true;
rbEasy.Active = true;
rbSmall.Active = true;
SetMapSize();
rbMSmall.Sensitive = false;
rbMMedium.Sensitive = false;
rbMLarge.Sensitive = false;
}
//Automatically set map sizes from screen & inventory size only in survival mode
private void OnRbSmallToggled(object sender, EventArgs e) {
if (rbSurvival.Active) {
this.SetMapSize();
}
}
private void OnRbMediumToggled(object sender, EventArgs e) {
if (rbSurvival.Active) {
this.SetMapSize();
}
}
private void OnRbLargeToggled(object sender, EventArgs e) {
if (rbSurvival.Active) {
this.SetMapSize();
}
}
//Sets map size from screen & inventory size
private void SetMapSize() {
if (rbSmall.Active) {
rbMLarge.Active = true;
}
else if (rbMedium.Active) {
rbMMedium.Active = true;
}
else if (rbLarge.Active) {
rbMSmall.Active = true;
}
}
private void OnBtnGenerateClicked(object sender, EventArgs e) {
//TODO: save settings somewhere
this.Hide();
this.ScreenInventorySetup();
this.GenerateMap();
GameGenerator.GameWindowInitialize();
}
// Calls GameGenerator to generate the map depending on the selected map size button
private void GenerateMap() {
string size;
if (rbMSmall.Active) {
size = "small";
}
else if (rbMMedium.Active) {
size = "medium";
}
else if (rbMLarge.Active) {
size = "large";
}
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() {
string gameWindow;
if (rbSmall.Active) {
gameWindow = "small";
}
else if (rbMedium.Active) {
gameWindow = "medium";
}
else if (rbLarge.Active) {
gameWindow = "large";
}
else {
throw new ArgumentException("No screen & inventory size was selected");
}
GameGenerator.GameWindowSizeSetup(gameWindow);
}
}
}
|