aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-03-13 12:30:41 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-03-13 12:30:41 +0200
commit37e3abdf91830cbec3664232f3ed1fad9b317dde (patch)
tree632000dfa8184ae7a7e9db6e2ab89b051f6dc65f
parent65d6ddb127e22652d4edebca2e47167a18ec8541 (diff)
downloadMundus-37e3abdf91830cbec3664232f3ed1fad9b317dde.tar
Mundus-37e3abdf91830cbec3664232f3ed1fad9b317dde.tar.gz
Mundus-37e3abdf91830cbec3664232f3ed1fad9b317dde.zip
Finished inventory and implimented breaking and placing structures on the map
-rw-r--r--Mundus/Mundus.csproj2
-rw-r--r--Mundus/Service/Calculate.cs12
-rw-r--r--Mundus/Service/Inventory.cs70
-rw-r--r--Mundus/Service/Mobs/MobFighting.cs7
-rw-r--r--Mundus/Service/Mobs/MobMoving.cs24
-rw-r--r--Mundus/Service/Mobs/MobTerraforming.cs50
-rw-r--r--Mundus/Service/SuperLayers/ImageController.cs8
-rw-r--r--Mundus/Service/SwitchItems.cs97
-rw-r--r--Mundus/Views/Windows/SmallGameWindow.cs101
-rw-r--r--Mundus/gtk-gui/Mundus.Views.Windows.SmallGameWindow.cs112
-rw-r--r--Mundus/gtk-gui/gui.stetic15
11 files changed, 307 insertions, 191 deletions
diff --git a/Mundus/Mundus.csproj b/Mundus/Mundus.csproj
index f3cede2..6145cd8 100644
--- a/Mundus/Mundus.csproj
+++ b/Mundus/Mundus.csproj
@@ -110,6 +110,8 @@
<Compile Include="Data\Tiles\ToolTypes.cs" />
<Compile Include="Service\Tiles\Items\Material.cs" />
<Compile Include="Service\Tiles\Items\Gear.cs" />
+ <Compile Include="Service\Mobs\MobFighting.cs" />
+ <Compile Include="Service\Mobs\MobTerraforming.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Service\" />
diff --git a/Mundus/Service/Calculate.cs b/Mundus/Service/Calculate.cs
index 7ccaf79..2c8cfa1 100644
--- a/Mundus/Service/Calculate.cs
+++ b/Mundus/Service/Calculate.cs
@@ -27,6 +27,18 @@ namespace Mundus.Service {
int startX = (LMI.Player.XPos - 2 <= MapSizes.CurrSize - size) ? LMI.Player.XPos - 2 : MapSizes.CurrSize - size;
if (startX < 0) startX = 0;
return startX;
+ }
+
+ //Screen buttons show only a certain part of the whole map
+ public static int CalculateYFromButton(int buttonYPos, int size) {
+ int newYPos = (LMI.Player.YPos - 2 >= 0) ? LMI.Player.YPos - 2 + buttonYPos : buttonYPos;
+ if (LMI.Player.YPos > MapSizes.CurrSize - 3) newYPos = buttonYPos + MapSizes.CurrSize - size;
+ return newYPos;
+ }
+ public static int CalculateXFromButton(int buttonXPos, int size) {
+ int newXPos = (LMI.Player.XPos - 2 >= 0) ? LMI.Player.XPos - 2 + buttonXPos : buttonXPos;
+ if (LMI.Player.XPos > MapSizes.CurrSize - 3) newXPos = buttonXPos + MapSizes.CurrSize - size;
+ return newXPos;
}
}
}
diff --git a/Mundus/Service/Inventory.cs b/Mundus/Service/Inventory.cs
index a60a2fb..89296dc 100644
--- a/Mundus/Service/Inventory.cs
+++ b/Mundus/Service/Inventory.cs
@@ -2,9 +2,8 @@
namespace Mundus.Service {
public class Inventory {
- public Tool Hand { get; set; }
- public Material[] Hotbar { get; set; }
- public Material[] Items { get; set; }
+ public ItemTile[] Hotbar { get; set; }
+ public ItemTile[] Items { get; set; }
public Gear[] Accessories { get; set; }
public Gear[] Gear { get; set; }
@@ -13,37 +12,58 @@ namespace Mundus.Service {
}
public void SetNewSizes(int screenInvSize) {
- this.Hotbar = new Material[screenInvSize - 1];
- this.Items = new Material[screenInvSize * screenInvSize];
+ this.Hotbar = new ItemTile[screenInvSize];
+ this.Items = new ItemTile[screenInvSize * screenInvSize];
this.Accessories = new Gear[screenInvSize * 2];
this.Gear = new Gear[screenInvSize];
}
- public void AddItem(string place, ItemTile newItem) {
- ItemTile[] tmp = null;
- switch (place.ToLower()) {
- case "hand": tmp[0] = this.Hand; break;
- case "hotbar": tmp = this.Hotbar; break;
- case "items": tmp = this.Items; break;
- case "accessories": tmp = this.Accessories; break;
- case "gear": tmp = this.Gear; break;
- }
+ public void AddToHotbar(ItemTile itemTile, int index) {
+ this.Hotbar[index] = itemTile;
+ }
- for (int i = 0; i < tmp.Length; i++) {
- if (tmp[i] == null) {
- tmp[i] = newItem;
- break;
- }
- }
+ public void DeleteFromHotbar(int index) {
+ this.Hotbar[index] = null;
+ }
+
+ public void AddToItems(ItemTile itemTile, int index) {
+ this.Items[index] = itemTile;
+ }
+
+ public void DeleteFromItems(int index) {
+ this.Items[index] = null;
+ }
+
+ public void EquipAccessory(Gear accessory, int index) {
+ this.Accessories[index] = accessory;
}
- public void RemoveItem(string place, int index) {
+ public void DeleteAccessory(int index) {
+ this.Accessories[index] = null;
+ }
+
+ public void EquipGear(Gear gear, int index) {
+ this.Gear[index] = gear;
+ }
+
+ public void DeleteGear(int index) {
+ this.Gear[index] = null;
+ }
+
+ public ItemTile GetTile(string place, int index) {
+ ItemTile toReturn = null;
+
switch (place.ToLower()) {
- case "hotbar": this.Hotbar[index] = null; break;
- case "items": this.Items[index] = null; break;
- case "accessories": this.Accessories[index] = null; break;
- case "gear": this.Gear[index] = null; break;
+ case "hotbar": toReturn = this.Hotbar[index]; break;
+ case "items": toReturn = this.Items[index]; break;
+ case "accessories": toReturn = this.Accessories[index]; break;
+ case "gear": toReturn = this.Gear[index]; break;
}
+ return toReturn;
+ }
+
+ public static ItemTile GetPlayerItem(string place, int index) {
+ return Data.Superlayers.Mobs.LMI.Player.Inventory.GetTile(place, index);
}
}
}
diff --git a/Mundus/Service/Mobs/MobFighting.cs b/Mundus/Service/Mobs/MobFighting.cs
new file mode 100644
index 0000000..def8e4c
--- /dev/null
+++ b/Mundus/Service/Mobs/MobFighting.cs
@@ -0,0 +1,7 @@
+using System;
+namespace Mundus.Service.Mobs {
+ public class MobFighting {
+ public MobFighting() {
+ }
+ }
+}
diff --git a/Mundus/Service/Mobs/MobMoving.cs b/Mundus/Service/Mobs/MobMoving.cs
index 8ac821b..04ce9aa 100644
--- a/Mundus/Service/Mobs/MobMoving.cs
+++ b/Mundus/Service/Mobs/MobMoving.cs
@@ -7,25 +7,29 @@ namespace Mundus.Service.Mobs {
ChangePosition(LMI.Player, yPos, xPos, size);
}
- public static void ChangePosition(IMob mob, int buttonYPos, int buttonXPos, int size) {
- int newYPos = (LMI.Player.YPos - 2 >= 0) ? LMI.Player.YPos - 2 + buttonYPos : buttonYPos;
- if (LMI.Player.YPos > MapSizes.CurrSize - 3) newYPos = buttonYPos + MapSizes.CurrSize - size;
- int newXPos = (LMI.Player.XPos - 2 >= 0) ? LMI.Player.XPos - 2 + buttonXPos : buttonXPos;
- if (LMI.Player.XPos > MapSizes.CurrSize - 3) newXPos = buttonXPos + MapSizes.CurrSize - size;
-
- if (newYPos >= 0 && newXPos >= 0 && newYPos < MapSizes.CurrSize && newXPos < MapSizes.CurrSize) {
- ChangePosition(mob, newYPos, newXPos);
+ public static void ChangePosition(IMob mob, int yPos, int xPos, int size) {
+ if (yPos >= 0 && xPos >= 0 && yPos < MapSizes.CurrSize && xPos < MapSizes.CurrSize) {
+ ChangePosition(mob, yPos, xPos);
}
}
public static void ChangePosition(IMob mob, int yPos, int xPos) {
- if (mob.CurrSuperLayer.GetStructureLayerTile( yPos, xPos ) == null ||
- mob.CurrSuperLayer.GetStructureLayerTile( yPos, xPos ).IsWalkable) {
+ if (Walkable(mob, yPos, xPos)) {
mob.CurrSuperLayer.RemoveMobFromPosition( mob.YPos, mob.XPos );
mob.YPos = yPos;
mob.XPos = xPos;
mob.CurrSuperLayer.SetMobAtPosition( mob.Tile, yPos, xPos );
}
+ }
+
+ private static bool Walkable(IMob mob, int yPos, int xPos) {
+ return (mob.CurrSuperLayer.GetStructureLayerTile(yPos, xPos) == null ||
+ mob.CurrSuperLayer.GetStructureLayerTile(yPos, xPos).IsWalkable) ||
+ mob.CurrSuperLayer.GetMobLayerTile(yPos, xPos) != null;
+ }
+
+ public static bool PlayerCanWalkTo(int yPos, int xPos) {
+ return Walkable(LMI.Player, yPos, xPos);
}
}
}
diff --git a/Mundus/Service/Mobs/MobTerraforming.cs b/Mundus/Service/Mobs/MobTerraforming.cs
new file mode 100644
index 0000000..e80f7cb
--- /dev/null
+++ b/Mundus/Service/Mobs/MobTerraforming.cs
@@ -0,0 +1,50 @@
+using Mundus.Data.Superlayers.Mobs;
+using Mundus.Data.SuperLayers;
+using Mundus.Service.Tiles.Items;
+
+namespace Mundus.Service.Mobs {
+ public static class MobTerraforming {
+ public static void PlayerDestroyAt(int mapYPos, int mapXPos, string place, int index) {
+ if (LMI.Player.Inventory.GetTile(place, index).GetType() == typeof(Tool)) {
+ var selTool = (Tool)LMI.Player.Inventory.GetTile(place, index);
+ if (LMI.Player.CurrSuperLayer.GetStructureLayerTile(mapYPos, mapXPos).ReqToolType == selTool.Type &&
+ LMI.Player.CurrSuperLayer.GetStructureLayerTile(mapYPos, mapXPos).ReqToolClass == selTool.Class) {
+ LMI.Player.CurrSuperLayer.SetStructureAtPosition(null, mapYPos, mapXPos);
+ }
+ }
+ }
+
+ public static void PlayerBuildAt(int mapYPos, int mapXPos, string inventoryPlace, int inventoryPlaceIndex) {
+ if (PlayerCanBuildAt(mapYPos, mapXPos)) {
+ Structure toPlace = null;
+
+ switch (inventoryPlace) {
+ case "hotbar": toPlace = (Structure)LMI.Player.Inventory.Hotbar[inventoryPlaceIndex]; break;
+ case "items": toPlace = (Structure)LMI.Player.Inventory.Items[inventoryPlaceIndex]; break;
+ }
+
+ if (toPlace != null) {
+ PlayerBuildAt(mapYPos, mapXPos, toPlace);
+ }
+ }
+ }
+
+ public static void PlayerBuildAt(int mapYPos, int mapXPos, Structure toPlace) {
+ LMI.Player.CurrSuperLayer.SetStructureAtPosition(toPlace, mapYPos, mapXPos);
+ }
+
+ public static void TryPlaceStructure(ISuperLayer superLayer, int yPos, int xPos, Structure toPlace) {
+ if (superLayer.GetStructureLayerTile(yPos, xPos) != null) {
+ superLayer.SetStructureAtPosition(toPlace, yPos, xPos);
+ }
+ }
+
+ public static bool PlayerCanBuildAt(int yPos, int xPos) {
+ return LMI.Player.CurrSuperLayer.GetStructureLayerTile(yPos, xPos) == null;
+ }
+
+ public static bool PlayerCanDestroyAt(int yPos, int xPos) {
+ return LMI.Player.CurrSuperLayer.GetStructureLayerTile(yPos, xPos) != null;
+ }
+ }
+}
diff --git a/Mundus/Service/SuperLayers/ImageController.cs b/Mundus/Service/SuperLayers/ImageController.cs
index f7b5c28..022c61c 100644
--- a/Mundus/Service/SuperLayers/ImageController.cs
+++ b/Mundus/Service/SuperLayers/ImageController.cs
@@ -55,14 +55,6 @@ namespace Mundus.Service.SuperLayers {
return img;
}
- public static Image GetHandImage() {
- Image img = new Image("blank_hand", IconSize.Dnd);
- if (LMI.Player.Inventory.Hand != null) {
- img = LMI.Player.Inventory.Hand.Texture;
- }
- return img;
- }
-
public static Image GetHotbarImage(int index) {
Image img = new Image("blank", IconSize.Dnd);
diff --git a/Mundus/Service/SwitchItems.cs b/Mundus/Service/SwitchItems.cs
index a8dcb5b..9f0a96e 100644
--- a/Mundus/Service/SwitchItems.cs
+++ b/Mundus/Service/SwitchItems.cs
@@ -3,66 +3,55 @@ using Mundus.Service.Tiles;
using Mundus.Service.Tiles.Items;
namespace Mundus.Service {
- public static class SwitchItems {
- private static string originType = null;
- private static ItemTile[] origin = null;
- private static int oIndex = -1;
-
- public static void SetOrigin(string originName, int originIndex) {
- ItemTile[] newOrigin = null;
-
+ public static class SwitchItems {
+ private static ItemTile[] origin = null;
+ private static int oIndex = -1;
+
+ public static void SetOrigin(string originName, int originIndex) {
+ ItemTile[] newOrigin = null;
+
switch (originName.ToLower()) {
- case "hand": newOrigin = new ItemTile[] { LMI.Player.Inventory.Hand }; break;
- case "hotbar": newOrigin = LMI.Player.Inventory.Hotbar; break;
- case "items": newOrigin = LMI.Player.Inventory.Items; break;
- case "accessories": newOrigin = LMI.Player.Inventory.Accessories; break;
- case "gear": newOrigin = LMI.Player.Inventory.Gear; break;
- }
- SetOrigin(originName, newOrigin, originIndex);
- }
-
- private static void SetOrigin(string newOriginType, ItemTile[] newOrigin, int originIndex) {
- originType = newOriginType;
- origin = newOrigin;
- oIndex = originIndex;
- }
-
- public static void ReplaceItems(string destination, int destinationIndex) {
- if (destination == originType) {
- ItemTile[] destinationLocation = null;
-
- switch (destination.ToLower()) {
- case "hand": destinationLocation = new ItemTile[] { LMI.Player.Inventory.Hand }; break;
- case "hotbar": destinationLocation = LMI.Player.Inventory.Hotbar; break;
- case "items": destinationLocation = LMI.Player.Inventory.Items; break;
- case "accessories": destinationLocation = LMI.Player.Inventory.Accessories; break;
- case "gear": destinationLocation = LMI.Player.Inventory.Gear; break;
- }
- ReplaceItems(destinationLocation, destinationIndex);
+ case "hotbar": newOrigin = LMI.Player.Inventory.Hotbar; break;
+ case "items": newOrigin = LMI.Player.Inventory.Items; break;
+ case "accessories": newOrigin = LMI.Player.Inventory.Accessories; break;
+ case "gear": newOrigin = LMI.Player.Inventory.Gear; break;
+ }
+ SetOrigin(newOrigin, originIndex);
+ }
+
+ private static void SetOrigin(ItemTile[] newOrigin, int originIndex) {
+ origin = newOrigin;
+ oIndex = originIndex;
+ }
+
+ public static void ReplaceItems(string destination, int destinationIndex) {
+ ItemTile[] destinationLocation = null;
+
+ switch (destination.ToLower()) {
+ case "hotbar": destinationLocation = LMI.Player.Inventory.Hotbar; break;
+ case "items": destinationLocation = LMI.Player.Inventory.Items; break;
+ case "accessories": destinationLocation = LMI.Player.Inventory.Accessories; break;
+ case "gear": destinationLocation = LMI.Player.Inventory.Gear; break;
+ }
+
+ var toTransfer = origin[oIndex];
+
+ if (toTransfer != null) {
+ if ((toTransfer.GetType() == typeof(Tool) && (destination == "hotbar" || destination == "items")) ||
+ ((toTransfer.GetType() == typeof(Material) || toTransfer.GetType() == typeof(Structure)) && (destination == "hotbar" || destination == "items")) ||
+ (toTransfer.GetType() == typeof(Gear) && (destination == "hotbar" || destination == "items" || destination == "accessories" || destination == "gear"))) {
+
+ origin[oIndex] = destinationLocation[destinationIndex];
+ destinationLocation[destinationIndex] = toTransfer;
+ }
}
- else {
- Reset();
- }
- }
-
- public static void ReplaceItems(ItemTile[] destination, int destinationIndex) {
- if (origin[0].GetType() == destination[0].GetType()) {
- var toTransfer = origin[oIndex];
- origin[oIndex] = destination[destinationIndex];
- destination[destinationIndex] = toTransfer;
- }
-
- Reset();
- }
- private static void Reset() {
- originType = null;
origin = null;
oIndex = -1;
}
-
- public static bool HasOrigin() {
- return origin != null && oIndex != -1;
+
+ public static bool HasOrigin() {
+ return origin != null && oIndex != -1;
}
}
}
diff --git a/Mundus/Views/Windows/SmallGameWindow.cs b/Mundus/Views/Windows/SmallGameWindow.cs
index 331f531..b4a8ca9 100644
--- a/Mundus/Views/Windows/SmallGameWindow.cs
+++ b/Mundus/Views/Windows/SmallGameWindow.cs
@@ -3,6 +3,7 @@ using Gtk;
using Mundus.Service;
using Mundus.Service.Mobs;
using Mundus.Service.SuperLayers;
+using Mundus.Service.Tiles.Items;
namespace Mundus.Views.Windows {
public partial class SmallGameWindow : Gtk.Window, IGameWindow {
@@ -322,8 +323,6 @@ namespace Mundus.Views.Windows {
}
public void PrintInventory() {
- btnH.Image = ImageController.GetHandImage();
-
//Prints hotbar
for (int i = 0; i < Size; i++) {
Image img = ImageController.GetHotbarImage(i);
@@ -333,6 +332,7 @@ namespace Mundus.Views.Windows {
case 2: btnH2.Image = img; break;
case 3: btnH3.Image = img; break;
case 4: btnH4.Image = img; break;
+ case 5: btnH5.Image = img; break;
}
}
@@ -408,135 +408,152 @@ namespace Mundus.Views.Windows {
//Screen buttons
protected void OnBtnP1Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(1);
+ React(1);
}
}
protected void OnBtnP2Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(2);
+ React(2);
}
}
protected void OnBtnP3Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(3);
+ React(3);
}
}
protected void OnBtnP4Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(4);
+ React(4);
}
}
protected void OnBtnP5Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(5);
+ React(5);
}
}
protected void OnBtnP6Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(6);
+ React(6);
}
}
protected void OnBtnP7Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(7);
+ React(7);
}
}
protected void OnBtnP8Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(8);
+ React(8);
}
}
protected void OnBtnP9Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(9);
+ React(9);
}
}
protected void OnBtnP10Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(10);
+ React(10);
}
}
protected void OnBtnP11Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(11);
+ React(11);
}
}
protected void OnBtnP12Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(12);
+ React(12);
}
}
protected void OnBtnP13Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(13);
+ React(13);
}
}
protected void OnBtnP14Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(14);
+ React(14);
}
}
protected void OnBtnP15Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(15);
+ React(15);
}
}
protected void OnBtnP16Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(16);
+ React(16);
}
}
protected void OnBtnP17Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(17);
+ React(17);
}
}
protected void OnBtnP18Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(18);
+ React(18);
}
}
protected void OnBtnP19Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(19);
+ React(19);
}
}
protected void OnBtnP20Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(20);
+ React(20);
}
}
protected void OnBtnP21Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(21);
+ React(21);
}
}
protected void OnBtnP22Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(22);
+ React(22);
}
}
protected void OnBtnP23Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(23);
+ React(23);
}
}
protected void OnBtnP24Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(24);
+ React(24);
}
}
protected void OnBtnP25Clicked(object sender, EventArgs e) {
if (!WindowController.PauseWindowVisible) {
- ChangePosition(25);
+ React(25);
}
}
- private void ChangePosition(int button) {
+ private void React(int button) {
int buttonYPos = (button - 1) / 5;
int buttonXPos = button - buttonYPos * 5 - 1;
- MobMoving.MovePlayer(buttonYPos, buttonXPos, Size);
+ int mapXPos = Calculate.CalculateXFromButton(buttonXPos, Size);
+ int mapYPos = Calculate.CalculateYFromButton(buttonYPos, Size);
+
+ if (!HasSelection()) {
+ MobMoving.MovePlayer(mapYPos, mapXPos, Size);
+ }
+ else {
+ var selType = Inventory.GetPlayerItem(selPlace, selIndex).GetType();
+ //try to do MobFighting
+ if (selType == typeof(Structure) && MobTerraforming.PlayerCanBuildAt(mapYPos, mapXPos)) {
+ MobTerraforming.PlayerBuildAt(mapYPos, mapXPos, selPlace, selIndex);
+
+ }
+ else if (selType == typeof(Tool) && MobTerraforming.PlayerCanDestroyAt(mapYPos, mapXPos)) {
+ MobTerraforming.PlayerDestroyAt(mapYPos, mapXPos, selPlace, selIndex);
+ }
+ ResetSelection();
+ }
this.PrintScreen();
if (this.MapMenuIsVisible()) {
@@ -826,19 +843,35 @@ namespace Mundus.Views.Windows {
}
}
+ private static string selPlace = null;
+ private static int selIndex = -1;
+ private static void ResetSelection() {
+ selPlace = null;
+ selIndex = -1;
+ }
+ private static bool HasSelection() {
+ return selPlace != null;
+ }
- private void SelectItem(string place, int position) {
- if (SwitchItems.HasOrigin()) {
- SwitchItems.ReplaceItems(place, position);
+ private void SelectItem(string place, int index) {
+ if (HasSelection()) {
+ ResetSelection();
+ SwitchItems.ReplaceItems(place, index);
} else {
- SwitchItems.SetOrigin(place, position);
+ selPlace = place;
+ selIndex = index;
+ SwitchItems.SetOrigin(place, index);
}
this.PrintInventory();
}
protected void OnBtnIG1Clicked(object sender, EventArgs e) {
- Mundus.Data.Superlayers.Mobs.LMI.Player.Inventory.AddItem("items");
+ Mundus.Data.Superlayers.Mobs.LMI.Player.Inventory.Hotbar[0] = new Service.Tiles.Items.Structure("boulder", Mundus.Data.Tiles.ToolTypes.Pickaxe, 1);
+ }
+
+ protected void OnBtnIG2Clicked(object sender, EventArgs e) {
+ Mundus.Data.Superlayers.Mobs.LMI.Player.Inventory.Hotbar[1] = new Service.Tiles.Items.Tool("blank_hand", Mundus.Data.Tiles.ToolTypes.Pickaxe, 1);
}
}
}
diff --git a/Mundus/gtk-gui/Mundus.Views.Windows.SmallGameWindow.cs b/Mundus/gtk-gui/Mundus.Views.Windows.SmallGameWindow.cs
index 10e424c..c3a392c 100644
--- a/Mundus/gtk-gui/Mundus.Views.Windows.SmallGameWindow.cs
+++ b/Mundus/gtk-gui/Mundus.Views.Windows.SmallGameWindow.cs
@@ -42,8 +42,6 @@ namespace Mundus.Views.Windows
private global::Gtk.Button btnGM3;
- private global::Gtk.Button btnH;
-
private global::Gtk.Button btnH1;
private global::Gtk.Button btnH2;
@@ -52,6 +50,8 @@ namespace Mundus.Views.Windows
private global::Gtk.Button btnH4;
+ private global::Gtk.Button btnH5;
+
private global::Gtk.Button btnI1;
private global::Gtk.Button btnI10;
@@ -658,24 +658,6 @@ namespace Mundus.Views.Windows
w33.XOptions = ((global::Gtk.AttachOptions)(4));
w33.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child tbUI.Gtk.Table+TableChild
- this.btnH = new global::Gtk.Button();
- this.btnH.WidthRequest = 50;
- this.btnH.HeightRequest = 50;
- this.btnH.CanFocus = true;
- this.btnH.Name = "btnH";
- this.btnH.UseUnderline = true;
- this.btnH.Relief = ((global::Gtk.ReliefStyle)(1));
- global::Gtk.Image w34 = new global::Gtk.Image();
- this.btnH.Image = w34;
- this.tbUI.Add(this.btnH);
- global::Gtk.Table.TableChild w35 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH]));
- w35.TopAttach = ((uint)(10));
- w35.BottomAttach = ((uint)(11));
- w35.LeftAttach = ((uint)(8));
- w35.RightAttach = ((uint)(9));
- w35.XOptions = ((global::Gtk.AttachOptions)(4));
- w35.YOptions = ((global::Gtk.AttachOptions)(4));
- // Container child tbUI.Gtk.Table+TableChild
this.btnH1 = new global::Gtk.Button();
this.btnH1.WidthRequest = 50;
this.btnH1.HeightRequest = 50;
@@ -683,16 +665,16 @@ namespace Mundus.Views.Windows
this.btnH1.Name = "btnH1";
this.btnH1.UseUnderline = true;
this.btnH1.Relief = ((global::Gtk.ReliefStyle)(1));
- global::Gtk.Image w36 = new global::Gtk.Image();
- this.btnH1.Image = w36;
+ global::Gtk.Image w34 = new global::Gtk.Image();
+ this.btnH1.Image = w34;
this.tbUI.Add(this.btnH1);
- global::Gtk.Table.TableChild w37 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH1]));
- w37.TopAttach = ((uint)(10));
- w37.BottomAttach = ((uint)(11));
- w37.LeftAttach = ((uint)(9));
- w37.RightAttach = ((uint)(10));
- w37.XOptions = ((global::Gtk.AttachOptions)(4));
- w37.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w35 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH1]));
+ w35.TopAttach = ((uint)(10));
+ w35.BottomAttach = ((uint)(11));
+ w35.LeftAttach = ((uint)(8));
+ w35.RightAttach = ((uint)(9));
+ w35.XOptions = ((global::Gtk.AttachOptions)(4));
+ w35.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child tbUI.Gtk.Table+TableChild
this.btnH2 = new global::Gtk.Button();
this.btnH2.WidthRequest = 50;
@@ -701,16 +683,16 @@ namespace Mundus.Views.Windows
this.btnH2.Name = "btnH2";
this.btnH2.UseUnderline = true;
this.btnH2.Relief = ((global::Gtk.ReliefStyle)(1));
- global::Gtk.Image w38 = new global::Gtk.Image();
- this.btnH2.Image = w38;
+ global::Gtk.Image w36 = new global::Gtk.Image();
+ this.btnH2.Image = w36;
this.tbUI.Add(this.btnH2);
- global::Gtk.Table.TableChild w39 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH2]));
- w39.TopAttach = ((uint)(10));
- w39.BottomAttach = ((uint)(11));
- w39.LeftAttach = ((uint)(10));
- w39.RightAttach = ((uint)(11));
- w39.XOptions = ((global::Gtk.AttachOptions)(4));
- w39.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w37 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH2]));
+ w37.TopAttach = ((uint)(10));
+ w37.BottomAttach = ((uint)(11));
+ w37.LeftAttach = ((uint)(9));
+ w37.RightAttach = ((uint)(10));
+ w37.XOptions = ((global::Gtk.AttachOptions)(4));
+ w37.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child tbUI.Gtk.Table+TableChild
this.btnH3 = new global::Gtk.Button();
this.btnH3.WidthRequest = 50;
@@ -719,16 +701,16 @@ namespace Mundus.Views.Windows
this.btnH3.Name = "btnH3";
this.btnH3.UseUnderline = true;
this.btnH3.Relief = ((global::Gtk.ReliefStyle)(1));
- global::Gtk.Image w40 = new global::Gtk.Image();
- this.btnH3.Image = w40;
+ global::Gtk.Image w38 = new global::Gtk.Image();
+ this.btnH3.Image = w38;
this.tbUI.Add(this.btnH3);
- global::Gtk.Table.TableChild w41 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH3]));
- w41.TopAttach = ((uint)(10));
- w41.BottomAttach = ((uint)(11));
- w41.LeftAttach = ((uint)(11));
- w41.RightAttach = ((uint)(12));
- w41.XOptions = ((global::Gtk.AttachOptions)(4));
- w41.YOptions = ((global::Gtk.AttachOptions)(4));
+ global::Gtk.Table.TableChild w39 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH3]));
+ w39.TopAttach = ((uint)(10));
+ w39.BottomAttach = ((uint)(11));
+ w39.LeftAttach = ((uint)(10));
+ w39.RightAttach = ((uint)(11));
+ w39.XOptions = ((global::Gtk.AttachOptions)(4));
+ w39.YOptions = ((global::Gtk.AttachOptions)(4));
// Container child tbUI.Gtk.Table+TableChild
this.btnH4 = new global::Gtk.Button();
this.btnH4.WidthRequest = 50;
@@ -737,10 +719,28 @@ namespace Mundus.Views.Windows
this.btnH4.Name = "btnH4";
this.btnH4.UseUnderline = true;
this.btnH4.Relief = ((global::Gtk.ReliefStyle)(1));
- global::Gtk.Image w42 = new global::Gtk.Image();
- this.btnH4.Image = w42;
+ global::Gtk.Image w40 = new global::Gtk.Image();
+ this.btnH4.Image = w40;
this.tbUI.Add(this.btnH4);
- global::Gtk.Table.TableChild w43 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH4]));
+ global::Gtk.Table.TableChild w41 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH4]));
+ w41.TopAttach = ((uint)(10));
+ w41.BottomAttach = ((uint)(11));
+ w41.LeftAttach = ((uint)(11));
+ w41.RightAttach = ((uint)(12));
+ w41.XOptions = ((global::Gtk.AttachOptions)(4));
+ w41.YOptions = ((global::Gtk.AttachOptions)(4));
+ // Container child tbUI.Gtk.Table+TableChild
+ this.btnH5 = new global::Gtk.Button();
+ this.btnH5.WidthRequest = 50;
+ this.btnH5.HeightRequest = 50;
+ this.btnH5.CanFocus = true;
+ this.btnH5.Name = "btnH5";
+ this.btnH5.UseUnderline = true;
+ this.btnH5.Relief = ((global::Gtk.ReliefStyle)(1));
+ global::Gtk.Image w42 = new global::Gtk.Image();
+ this.btnH5.Image = w42;
+ this.tbUI.Add(this.btnH5);
+ global::Gtk.Table.TableChild w43 = ((global::Gtk.Table.TableChild)(this.tbUI[this.btnH5]));
w43.TopAttach = ((uint)(10));
w43.BottomAttach = ((uint)(11));
w43.LeftAttach = ((uint)(12));
@@ -2937,6 +2937,8 @@ namespace Mundus.Views.Windows
this.btnMusic.Clicked += new global::System.EventHandler(this.OnBtnMusicClicked);
this.btnMap.Clicked += new global::System.EventHandler(this.OnBtnMapClicked);
this.btnInv.Clicked += new global::System.EventHandler(this.OnBtnInvClicked);
+ this.btnIG2.Clicked += new global::System.EventHandler(this.OnBtnIG2Clicked);
+ this.btnIG1.Clicked += new global::System.EventHandler(this.OnBtnIG1Clicked);
this.btnI9.Clicked += new global::System.EventHandler(this.OnBtnI9Clicked);
this.btnI8.Clicked += new global::System.EventHandler(this.OnBtnI8Clicked);
this.btnI7.Clicked += new global::System.EventHandler(this.OnBtnI7Clicked);
@@ -2962,11 +2964,11 @@ namespace Mundus.Views.Windows
this.btnI11.Clicked += new global::System.EventHandler(this.OnBtnI11Clicked);
this.btnI10.Clicked += new global::System.EventHandler(this.OnBtnI10Clicked);
this.btnI1.Clicked += new global::System.EventHandler(this.OnBtnI1Clicked);
- this.btnH4.Clicked += new global::System.EventHandler(this.OnBtnH5Clicked);
- this.btnH3.Clicked += new global::System.EventHandler(this.OnBtnH4Clicked);
- this.btnH2.Clicked += new global::System.EventHandler(this.OnBtnH3Clicked);
- this.btnH1.Clicked += new global::System.EventHandler(this.OnBtnH2Clicked);
- this.btnH.Clicked += new global::System.EventHandler(this.OnBtnH1Clicked);
+ this.btnH5.Clicked += new global::System.EventHandler(this.OnBtnH5Clicked);
+ this.btnH4.Clicked += new global::System.EventHandler(this.OnBtnH4Clicked);
+ this.btnH3.Clicked += new global::System.EventHandler(this.OnBtnH3Clicked);
+ this.btnH2.Clicked += new global::System.EventHandler(this.OnBtnH2Clicked);
+ this.btnH1.Clicked += new global::System.EventHandler(this.OnBtnH1Clicked);
this.btnG5.Clicked += new global::System.EventHandler(this.OnBtnG5Clicked);
this.btnG4.Clicked += new global::System.EventHandler(this.OnBtnG4Clicked);
this.btnG3.Clicked += new global::System.EventHandler(this.OnBtnG3Clicked);
diff --git a/Mundus/gtk-gui/gui.stetic b/Mundus/gtk-gui/gui.stetic
index d33a8c7..2ad7a06 100644
--- a/Mundus/gtk-gui/gui.stetic
+++ b/Mundus/gtk-gui/gui.stetic
@@ -399,6 +399,7 @@
<property name="WidthRequest">90</property>
<property name="CanFocus">True</property>
<property name="Label" translatable="yes">Creative</property>
+ <property name="Active">True</property>
<property name="DrawIndicator">True</property>
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
@@ -427,6 +428,7 @@
<property name="WidthRequest">90</property>
<property name="CanFocus">True</property>
<property name="Label" translatable="yes">Easy</property>
+ <property name="Active">True</property>
<property name="DrawIndicator">True</property>
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
@@ -508,6 +510,7 @@
<property name="WidthRequest">90</property>
<property name="CanFocus">True</property>
<property name="Label" translatable="yes">Large</property>
+ <property name="Active">True</property>
<property name="DrawIndicator">True</property>
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
@@ -563,6 +566,7 @@
<property name="MemberName" />
<property name="CanFocus">True</property>
<property name="Label" translatable="yes">Large</property>
+ <property name="Active">True</property>
<property name="DrawIndicator">True</property>
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
@@ -1681,7 +1685,7 @@
</packing>
</child>
<child>
- <widget class="Gtk.Button" id="btnH">
+ <widget class="Gtk.Button" id="btnH1">
<property name="MemberName" />
<property name="WidthRequest">50</property>
<property name="HeightRequest">50</property>
@@ -1709,7 +1713,7 @@
</packing>
</child>
<child>
- <widget class="Gtk.Button" id="btnH1">
+ <widget class="Gtk.Button" id="btnH2">
<property name="MemberName" />
<property name="WidthRequest">50</property>
<property name="HeightRequest">50</property>
@@ -1737,7 +1741,7 @@
</packing>
</child>
<child>
- <widget class="Gtk.Button" id="btnH2">
+ <widget class="Gtk.Button" id="btnH3">
<property name="MemberName" />
<property name="WidthRequest">50</property>
<property name="HeightRequest">50</property>
@@ -1765,7 +1769,7 @@
</packing>
</child>
<child>
- <widget class="Gtk.Button" id="btnH3">
+ <widget class="Gtk.Button" id="btnH4">
<property name="MemberName" />
<property name="WidthRequest">50</property>
<property name="HeightRequest">50</property>
@@ -1793,7 +1797,7 @@
</packing>
</child>
<child>
- <widget class="Gtk.Button" id="btnH4">
+ <widget class="Gtk.Button" id="btnH5">
<property name="MemberName" />
<property name="WidthRequest">50</property>
<property name="HeightRequest">50</property>
@@ -2582,6 +2586,7 @@
<property name="Type">TextAndIcon</property>
<property name="Label" translatable="yes" />
<property name="UseUnderline">True</property>
+ <signal name="Clicked" handler="OnBtnIG2Clicked" />
</widget>
<packing>
<property name="TopAttach">14</property>