This repository has been archived by the owner on Dec 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Global.cs
100 lines (82 loc) · 2.99 KB
/
Global.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework.Input;
using TaiyouScriptEngine.Desktop.Taiyou;
namespace TaiyouScriptEngine.Desktop
{
public class Global
{
// Directories
public static string RegistryDir = "";
public static string SpriteDir = "";
public static string FontDir = "";
public static string GameFolder = "";
public static string SourceFolderFilter = "";
public static string TaiyouDir = "";
public static MouseState oldState;
public static bool DefaultValuesSet = false;
public static void UpdateGlobalVariables()
{
MouseState state = Mouse.GetState();
ChangeVar("M.X", state.X, "Int");
ChangeVar("M.Y", state.Y, "Int");
if (!DefaultValuesSet)
{
DefaultValuesSet = true;
ChangeVar("MLP.X", 0, "Int");
ChangeVar("MLP.Y", 0, "Int");
ChangeVar("MLR.X", 0, "Int");
ChangeVar("MLR.Y", 0, "Int");
ChangeVar("MRP.X", 0, "Int");
ChangeVar("MRP.Y", 0, "Int");
ChangeVar("MRR.X", 0, "Int");
ChangeVar("MRR.Y", 0, "Int");
}
switch (state.LeftButton)
{
case ButtonState.Pressed:
ChangeVar("MLP.X", state.X, "Int");
ChangeVar("MLP.Y", state.Y, "Int");
break;
case ButtonState.Released:
if (oldState.LeftButton == ButtonState.Pressed)
{
ChangeVar("MLR.X", state.X, "Int");
ChangeVar("MLR.Y", state.Y, "Int");
}
break;
}
switch (state.RightButton)
{
case ButtonState.Pressed:
ChangeVar("MRP.X", state.X, "Int");
ChangeVar("MRP.Y", state.Y, "Int");
break;
case ButtonState.Released:
if (oldState.RightButton == ButtonState.Pressed)
{
ChangeVar("MRR.X", state.X, "Int");
ChangeVar("MRR.Y", state.Y, "Int");
}
break;
}
oldState = state;
}
public static void ChangeVar(string VarName, dynamic VarValue, string VarType)
{
int VarIndex = Taiyou.Global.VarList_Keys.IndexOf(VarName);
// If it does not exist, add the variable
if (VarIndex == -1)
{
Taiyou.Global.VarList.Add(new Variable(VarType, VarValue, VarName));
Taiyou.Global.VarList_Keys.Add(VarName);
} // If exist, update it's value
else
{
Taiyou.Global.VarList[VarIndex].Set_Value(VarValue);
}
}
}
}