forked from jadaradix/dsgamemaker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathActionsLib.cs
More file actions
105 lines (100 loc) · 4.15 KB
/
ActionsLib.cs
File metadata and controls
105 lines (100 loc) · 4.15 KB
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
namespace DS_Game_Maker
{
static class ActionsLib
{
public static string ActionEquateDisplay(string ActionName, string ActionArguments)
{
string Returnable = string.Empty;
foreach (string Y in File.ReadAllLines(Constants.AppDirectory + "Actions/" + ActionName.Split('\\')[1] + ".action"))
{
if (Y.StartsWith("DISPLAY "))
{
Returnable = Y.Substring(8);
break;
}
}
if (Returnable.Length == 0)
return ActionName;
foreach (string Y in File.ReadAllLines(Constants.AppDirectory + "Actions/" + ActionName.Split('\\')[1] + ".action"))
{
for (int Z = 0, loopTo = (int)DSGMlib.HowManyChar(ActionArguments, ";"); Z <= loopTo; Z++)
{
string Argument = DSGMlib.iGet(ActionArguments, (byte)Z, ";");
string StringThing = Argument;
if (StringThing == "1")
StringThing = "true";
if (StringThing == "0")
StringThing = "false";
if (StringThing == "<" | StringThing == ">" | StringThing == ">=" | StringThing == "<=" | StringThing == "==")
{
StringThing = ScriptsLib.ComparativeToString(StringThing);
}
string ScreenThing = Argument;
if (ScreenThing == "1")
ScreenThing = "Top Screen";
if (ScreenThing == "0")
ScreenThing = "Bottom Screen";
Returnable = Returnable.Replace("$" + (Z + 1).ToString() + "$", StringThing);
Returnable = Returnable.Replace("%" + (Z + 1).ToString() + "%", ScreenThing);
Returnable = Returnable.Replace("!" + (Z + 1).ToString() + "!", Argument);
}
}
Returnable = Returnable.Replace("<com>", ",");
return Returnable;
}
public static bool ActionIsConditional(string ActionName)
{
foreach (string X_ in File.ReadAllLines(Constants.AppDirectory + "Actions/" + ActionName.Split('\\')[1] + ".action"))
{
string X = X_;
if (X.StartsWith("CONDITION "))
{
X = X.Substring("CONDITION".Length + 1);
return X == "1";
}
}
return false;
}
public static string ActionGetIconPath(string ActionName, bool UseFullPath)
{
string Returnable = "Empty.png";
foreach (string X in File.ReadAllLines(Constants.AppDirectory + "Actions/" + ActionName.Split('\\')[1] + ".action"))
{
if (X.StartsWith("ICON "))
Returnable = X.Substring(5);
}
if (!File.Exists(Constants.AppDirectory + "ActionIcons/" + Returnable))
Returnable = "Empty.png";
if (UseFullPath)
Returnable = Constants.AppDirectory + "ActionIcons/" + Returnable;
return Returnable;
}
public static Bitmap ActionGetIcon(string ActionName)
{
var TBMP = new Bitmap(32, 32);
var TBMPGFX = Graphics.FromImage(TBMP);
Bitmap TIcon = (Bitmap)DSGMlib.PathToImage(ActionGetIconPath(ActionName, true));
if (TIcon.Width == 32)
{
TBMPGFX.DrawImageUnscaled(Properties.Resources.ActionBacker, 0, 0);
TBMPGFX.DrawImageUnscaled(TIcon, new Point(0, 0));
}
else
{
if (ActionIsConditional(ActionName))
{
TBMPGFX.DrawImageUnscaled(DSGMlib.ActionConditionalBG, 0, 0);
}
else
{
TBMPGFX.DrawImageUnscaled(DSGMlib.ActionBG, 0, 0);
}
TBMPGFX.DrawImageUnscaled(TIcon, new Point(8, 8));
}
TBMPGFX.Dispose();
TIcon.Dispose();
return TBMP;
}
}
}