Merge branch '138-toggle-free-look-with-hotkey' into main/gingo-test
[ryzomcore.git] / ryzom / client / src / interfaces_manager / interf_script.cpp
blob734b9909894cad5af0ba20eb3453139f21c1c42b
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "stdpch.h"
22 /////////////
23 // Include //
24 /////////////
25 #include "interf_script.h"
28 //////////////
29 // Function //
30 //////////////
31 //-----------------------------------------------
32 // getFloat :
33 // Get a "float" in the script.
34 //-----------------------------------------------
35 float getFloat()
37 char delimiter[] = "[] \t";
38 char *ptr = strtok(NULL, delimiter);
39 if(ptr != NULL)
41 float val;
42 NLMISC::fromString(ptr, val);
43 return val;
45 return 0.f;
46 }// getFloat //
48 //-----------------------------------------------
49 // getInt :
50 // Get an "int" in the script.
51 //-----------------------------------------------
52 sint getInt()
54 char delimiter[] = "[] \t";
55 char *ptr = strtok(NULL, delimiter);
56 if(ptr != NULL)
57 return atoi(ptr);
58 return 0;
59 }// getInt //
61 //-----------------------------------------------
62 // getRGBA :
63 // Get all value for a RGBA in the script.
64 //-----------------------------------------------
65 CRGBA getRGBA()
67 char delimiter[] = "[] \t";
68 uint8 rgba[4] = {255,255,255,255};
69 char *ptr;
71 for(uint rgbaIndex = 0; rgbaIndex<4; ++rgbaIndex)
73 ptr = strtok(NULL, delimiter);
74 if(ptr != NULL)
75 rgba[rgbaIndex] = atoi(ptr);
76 else
77 break;
79 return CRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
80 }// getRGBA //
84 //-----------------------------------------------
85 // getVector :
86 // Get all values for a vector in the script.
87 //-----------------------------------------------
88 std::vector<float> getVectorOfFloat(uint8 nbCol)
90 std::vector<float> vect;
91 float val;
92 char delimiter[] = "[] \t";
94 char *ptr;
96 for (uint8 i = 0 ; i< nbCol ; ++i)
98 ptr = strtok(NULL, delimiter);
99 if(ptr != NULL)
101 NLMISC::fromString(ptr, val);
102 if (val != 0.0f)
103 vect.push_back(val);
105 else
106 break;
110 return vect;
111 }// getVector //
114 //-----------------------------------------------
115 // getHotSpot :
116 // Get the Hot Spot of a control.
117 //-----------------------------------------------
118 CControl::THotSpot getHotSpot()
120 char delimiter[] = "[] \t";
121 char *ptr = strtok(NULL, delimiter);
122 if(ptr != NULL)
124 if (strcmp(ptr, "TL") == 0)
125 return CControl::HS_TL;
126 else if(strcmp(ptr, "TM") == 0)
127 return CControl::HS_TM;
128 else if(strcmp(ptr, "TR") == 0)
129 return CControl::HS_TR;
130 else if(strcmp(ptr, "ML") == 0)
131 return CControl::HS_ML;
132 else if(strcmp(ptr, "MR") == 0)
133 return CControl::HS_MR;
134 else if(strcmp(ptr, "BL") == 0)
135 return CControl::HS_BL;
136 else if(strcmp(ptr, "BM") == 0)
137 return CControl::HS_BM;
138 else if(strcmp(ptr, "BR") == 0)
139 return CControl::HS_BR;
142 // Return Middle Middle if it's middle middle or unknown.
143 return CControl::HS_MM;
144 }// getHotSpot //
146 //-----------------------------------------------
147 // getBGMode :
148 // Get the display mode for the background.
149 //-----------------------------------------------
150 COSD::TBG getBGMode()
152 char delimiter[] = "[] \t";
153 char *ptr = strtok(NULL, delimiter);
154 if(ptr != NULL)
156 if (strcmp(ptr, "none") == 0)
157 return COSD::BG_none;
158 else if(strcmp(ptr, "plain") == 0)
159 return COSD::BG_plain;
160 else if(strcmp(ptr, "stretch") == 0)
161 return COSD::BG_stretch;
164 // Default is no background.
165 return COSD::BG_none;
166 }// getBGMode //
168 //-----------------------------------------------
169 // getBGMode2 :
170 // Get the display mode for the background.
171 //-----------------------------------------------
172 CButtonBase::TBG getBGMode2()
174 char delimiter[] = "[] \t";
175 char *ptr = strtok(NULL, delimiter);
176 if(ptr != NULL)
178 if (strcmp(ptr, "none") == 0)
179 return CButtonBase::BG_none;
180 else if(strcmp(ptr, "plain") == 0)
181 return CButtonBase::BG_plain;
182 else if(strcmp(ptr, "stretch") == 0)
183 return CButtonBase::BG_stretch;
186 // Default is no background.
187 return CButtonBase::BG_none;
188 }// getBGMode2 //
190 //-----------------------------------------------
191 // getTBMode :
192 // Get the display mode for the Title Bar.
193 //-----------------------------------------------
194 COSD::TTB getTBMode()
196 char delimiter[] = "[] \t";
197 char *ptr = strtok(NULL, delimiter);
198 if(ptr != NULL)
200 if (strcmp(ptr, "none") == 0)
201 return COSD::TB_none;
202 else if(strcmp(ptr, "plain") == 0)
203 return COSD::TB_plain;
204 else if(strcmp(ptr, "stretch") == 0)
205 return COSD::TB_stretch;
208 // Default is no background.
209 return COSD::TB_none;
210 }// getTBMode //