32 Coords[0] = Coords[1] = INT_MAX;
40 for (; i <
num; i++) {
56 Assert(
sizeof(buf2) >= (
sizeof(buf) + 3) );
89 }
else if (!
stricmp(buf,
"Button")) {
102 while (temp_ocie.
Parse()) {
103 Subentries.push_back(temp_ocie);
131 while (temp_ocie.
Parse()) {
132 Entries.push_back(temp_ocie);
144 if (ClassInfoParsed) {
153 ScreenClassInfo.
Parse();
158 flag = sciep->
Parse();
166 ClassInfoParsed =
true;
170 mprintf((
"WMCGUI: Unable to parse '%s'! Error message = %s.\n", filename, e.what()));
191 if (num_frames > 1) {
194 if (num_frames > 2) {
197 if (num_frames > 3) {
200 if (num_frames > 4) {
275 if (cw != w || ch != h) {
276 Warning(
LOCATION,
"Grouped image size unequal; Handle number %d under $%s: has a different size than base image type",
i, tag);
287 if (Coords[0]!=INT_MAX && x!=NULL) {
291 if (Coords[1]!=INT_MAX && y!=NULL) {
301 return Entries[
id].GetImageHandle(handle_num);
306 return Entries[
id].GetCoords(x, y);
312 if (Coords[0] != INT_MAX && x != NULL) {
316 if (Coords[1] != INT_MAX && y != NULL) {
320 if (Coords[2] != INT_MAX && w != NULL) {
324 if (Coords[3] != INT_MAX && h != NULL) {
344 if (OwnerSystem != NULL) {
348 ScreenClassInfo = NULL;
356 for (; cgp !=
END_OF_LIST(&Guiobjects); cgp = cgp_next) {
367 if (cgp->Parent != NULL && cgp->Parent->InfoEntry != NULL) {
368 len = cgp->Parent->InfoEntry->Subentries.size();
370 for (i = 0; i <
len; i++) {
371 if (cgp->Parent->InfoEntry->Subentries[i].Name == cgp->Name) {
372 return &cgp->Parent->InfoEntry->Subentries[
i];
376 for (i = 0; i <
len; i++) {
377 if ( cgp->Parent->InfoEntry->Subentries[i].Name.size() == 0
378 && cgp->Parent->InfoEntry->Subentries[
i].Object == cgp->Type ) {
379 return &cgp->Parent->InfoEntry->Subentries[
i];
382 }
else if (cgp->Parent == NULL && ScreenClassInfo != NULL) {
383 len = ScreenClassInfo->Entries.size();
384 for (i = 0; i <
len; i++) {
385 if (ScreenClassInfo->Entries[i].Name == cgp->Name) {
386 return &ScreenClassInfo->Entries[
i];
390 for (i = 0; i <
len; i++) {
391 if( ScreenClassInfo->Entries[i].Name.size() == 0 &&
392 ScreenClassInfo->Entries[
i].Object == cgp->Type ) {
393 return &ScreenClassInfo->Entries[
i];
400 if (OwnerSystem != NULL) {
403 for (i = 0; i <
len; i++) {
404 if (OwnerSystem->
GetClassInfo()->Entries[
i].Name == cgp->Name) {
409 for (i = 0; i <
len; i++) {
410 if( OwnerSystem->
GetClassInfo()->Entries[
i].Name.size() == 0 &&
411 OwnerSystem->
GetClassInfo()->Entries[
i].Object == cgp->Type) {
426 if(new_gauge == NULL) {
434 if (tgp->Name == new_gauge->Name) {
438 if (tgp->Type == new_gauge->Type) {
446 Warning(
LOCATION,
"Attempt to create another object with name '%s'; new object type was %d, existing object type was %d. This may cause null pointer issues.", tgp->Name.c_str(), new_gauge->Type, tgp->Type);
455 new_gauge->OwnerSystem = OwnerSystem;
456 new_gauge->OwnerScreen =
this;
461 new_gauge->GetOIECoords(&new_gauge->Coords[0], &new_gauge->Coords[1], &new_gauge->Coords[2], &new_gauge->Coords[3]);
470 DeletionCache.push_back(dgp);
477 bool SomethingPressed =
false;
479 if (
NOT_EMPTY(&Guiobjects) && doevents) {
487 for (; cgp !=
END_OF_LIST(&Guiobjects); cgp = cgp_prev) {
490 cgp->LastStatus = cgp->Status;
495 if (OwnerSystem->
GetMouseX() >= cgp->Coords[0]
496 && OwnerSystem->
GetMouseX() <= cgp->Coords[2]
497 && OwnerSystem->
GetMouseY() >= cgp->Coords[1]
498 && OwnerSystem->
GetMouseY() <= cgp->Coords[3]) {
501 SomethingPressed =
true;
506 cgp->
OnFrame(frametime, &status);
510 for (
size_t i = DeletionCache.size();
i > 0;
i--) {
511 delete DeletionCache[
i-1];
512 DeletionCache.pop_back();
535 if(SomethingPressed) {
545 GraspedGuiobject=ActiveObject=NULL;
548 ClassInfoParsed =
false;
555 for (; csp !=
END_OF_LIST(&Screens); csp = csp_next) {
566 csp->OwnerSystem =
this;
579 if (csp == in_screen) {
580 csp->prev->next = csp->next;
581 csp->next->prev = csp->prev;
584 csp->OwnerSystem = NULL;
593 if (sciep->
GetName() == screen_name) {
607 bool something_pressed =
false;
644 if (GraspedGuiobject != NULL) {
645 if (Status & GraspingButton) {
646 something_pressed =
true;
647 GraspedGuiobject->
SetPosition(MouseX - GraspedDiff[0], MouseY - GraspedDiff[1]);
650 GraspedGuiobject = NULL;
659 something_pressed =
true;
668 if (something_pressed) {
681 while (cgp->Parent != NULL) {
698 GraspedGuiobject = cgp;
699 GraspingButton = button;
700 GraspedDiff[0] = MouseX - cgp->Coords[0];
701 GraspedDiff[1] = MouseY - cgp->Coords[1];
704 void GUISystem::DestroyClassInfo()
711 ClassInfoParsed =
false;
718 LastStatus = Status = 0;
722 CloseFunction = NULL;
729 if (x_width == 0 || y_height == 0) {
734 if (in_Name.length() < 1) {
741 Coords[2] = x_coord + x_width;
742 Coords[3] = y_coord + y_height;
759 if (CloseFunction != NULL) {
772 if (
EMPTY(&Children) ) {
800 cgp->OwnerSystem = OwnerSystem;
801 cgp->OwnerScreen = OwnerScreen;
804 cgp->Coords[0] += Coords[0];
805 cgp->Coords[1] += Coords[1];
806 cgp->Coords[2] += Coords[0];
807 cgp->Coords[3] += Coords[1];
812 cgp->GetOIECoords(&cgp->Coords[0], &cgp->Coords[1], &cgp->Coords[2], &cgp->Coords[3]);
834 cgp->OwnerSystem = OwnerSystem;
835 cgp->OwnerScreen = OwnerScreen;
838 cgp->Coords[0] += ChildCoords[0];
839 cgp->Coords[1] += ChildCoords[1];
840 cgp->Coords[2] += ChildCoords[0];
841 cgp->Coords[3] += ChildCoords[1];
846 cgp->GetOIECoords(&cgp->Coords[0], &cgp->Coords[1], &cgp->Coords[2], &cgp->Coords[3]);
855 if (OwnerScreen != NULL) {
881 for ( ; (cgp != NULL) && (cgp !=
END_OF_LIST(&Children)); cgp = cgp_prev) {
883 cgp->LastStatus = cgp->Status;
887 if (OwnerSystem->
GetMouseX() >= cgp->Coords[0]
888 && OwnerSystem->
GetMouseX() <= cgp->Coords[2]
889 && OwnerSystem->
GetMouseY() >= cgp->Coords[1]
890 && OwnerSystem->
GetMouseY() <= cgp->Coords[3]) {
897 cgp->
OnFrame(frametime, &Status);
906 (*unused_queue) &= ~GST_MOUSE_OVER;
942 (*unused_queue) &= ~GST_KEYBOARD_KEYPRESS;
947 if (!(Status &
GST_MOUSE_OVER) && (LastStatus & GST_MOUSE_OVER)) {
974 if (InfoEntry!=NULL) {
997 int GUIObject::GetOIECoords(
int *x1,
int *y1,
int *x2,
int *y2)
999 if (InfoEntry != NULL) {
1001 if (Parent != NULL) {
1004 *x1 += Parent->ChildCoords[2];
1006 *x1 += Parent->ChildCoords[0];
1011 *y1 += Parent->ChildCoords[3];
1013 *y1 += Parent->ChildCoords[1];
1017 if (rv & CIE_GC_X_SET) {
1024 if (rv & CIE_GC_Y_SET) {
1061 if (dx == 0 && dy == 0) {
1065 if (Parent != NULL) {
1067 if (Coords[2] + dx > Parent->Coords[2]) {
1068 dx = Parent->Coords[2] - Coords[2];
1071 dy = Parent->Coords[3] - Coords[3];
1076 dx = Parent->Coords[0] - Coords[0];
1079 dy = Parent->Coords[1] - Coords[1];
1092 int CornerWidths[4];
1109 bool custom_top =
true;
1137 CornerWidths[0] = BorderSizes[0];
1143 CornerWidths[1] = BorderSizes[2];
1149 CornerWidths[2] = BorderSizes[0];
1155 CornerWidths[3] = BorderSizes[2];
1160 ChildCoords[0] = Coords[0] + BorderSizes[0];
1162 ChildCoords[1] = Coords[1] + BorderSizes[1];
1166 ChildCoords[2] = Coords[2] - BorderSizes[2];
1167 ChildCoords[3] = Coords[3] - BorderSizes[3];
1170 ChildCoords[2] = Coords[2] = 0;
1173 ChildCoords[3] = Coords[3] = 0;
1178 if (cgp->Coords[0] < ChildCoords[0]) {
1179 cgp->
SetPosition(ChildCoords[0], cgp->Coords[1] + BorderSizes[0]);
1181 if (cgp->Coords[1] < ChildCoords[1]) {
1182 cgp->
SetPosition(cgp->Coords[0], Coords[1] + BorderSizes[1]);
1186 if (cgp->Coords[2] > ChildCoords[2] && !(Style & GS_NOAUTORESIZEX)) {
1187 ChildCoords[2] = cgp->Coords[2];
1188 Coords[2] = cgp->Coords[2] + BorderSizes[2];
1190 if (cgp->Coords[3] > ChildCoords[3] && !(Style & GS_NOAUTORESIZEY)) {
1191 ChildCoords[3] = cgp->Coords[3];
1192 Coords[3] = cgp->Coords[3] + BorderSizes[3];
1197 if (!(Style & WS_NOTITLEBAR)) {
1198 int close_w = 0,close_h = 0;
1199 int hide_w = 0, hide_h = 0;
1213 int caption_min_size;
1214 if (Caption.size() > 0) {
1216 caption_min_size = w + close_w + hide_w + 5;
1218 caption_min_size = close_w + hide_w;
1221 if ((Coords[2] - Coords[0]) < (caption_min_size)) {
1222 Coords[2] = Coords[0] + caption_min_size + BorderSizes[0] + BorderSizes[2];
1225 if (Caption.size() > 0) {
1228 CaptionCoords[0] = Coords[0] + BorderSizes[0];
1229 CaptionCoords[1] = Coords[1] + BorderSizes[1];
1234 num = (
float) w / cw;
1235 CaptionRectList =
bitmap_rect_list(Coords[0] + CornerWidths[2], Coords[1], w, ch, 0, 0, 1.0
f, 1.0
f);
1239 CaptionCoords[0] = Coords[0] + (((Coords[2]-Coords[0]) - w - (close_w + hide_w)) / 2);
1240 CaptionCoords[1] = Coords[1] + BorderSizes[1];
1242 CaptionCoords[2] = CaptionCoords[0] +
w;
1243 CaptionCoords[3] = CaptionCoords[1] +
h;
1247 CloseCoords[0] = Coords[2] - close_w;
1248 CloseCoords[1] = Coords[1] + BorderSizes[1];
1250 CloseCoords[2] = CloseCoords[0] + close_w;
1251 CloseCoords[3] = CloseCoords[1] + close_h;
1254 HideCoords[0] = CloseCoords[0] - hide_w;
1255 HideCoords[1] = CloseCoords[1];
1257 HideCoords[2] = HideCoords[0] + hide_w;
1258 HideCoords[3] = HideCoords[1] + hide_h;
1264 num = (
float)((Coords[2]-CornerWidths[3])-(Coords[0]+CornerWidths[2])) / (
float)w;
1270 num = (
float)((Coords[2]-CornerWidths[3])-(Coords[0]+CornerWidths[2])) / (
float)w;
1276 num = (
float)((Coords[3]-BorderSizes[3])-(Coords[1]+BorderSizes[1])) / (
float)
h;
1281 num = (
float)((Coords[3]-BorderSizes[3])-(Coords[1]+BorderSizes[1])) / (
float)
h;
1290 if (OwnerSystem->GetMouseX() >= HideCoords[0]
1291 && OwnerSystem->GetMouseX() <= HideCoords[2]
1292 && OwnerSystem->GetMouseY() >= HideCoords[1]
1293 && OwnerSystem->GetMouseY() <= HideCoords[3]) {
1294 HideHighlight =
true;
1296 HideHighlight =
false;
1299 if (OwnerSystem->GetMouseX() >= CloseCoords[0]
1300 && OwnerSystem->GetMouseX() <= CloseCoords[2]
1301 && OwnerSystem->GetMouseY() >= CloseCoords[1]
1302 && OwnerSystem->GetMouseY() <= CloseCoords[3]) {
1303 CloseHighlight =
true;
1305 CloseHighlight =
false;
1313 OwnerSystem->SetActiveObject(
this);
1319 if ((OwnerSystem->GetGraspedObject() == NULL)
1321 && OwnerSystem->GetMouseX() >= CaptionCoords[0]
1322 && ((OwnerSystem->GetMouseX() < CaptionCoords[2]) || ((Style &
WS_NOTITLEBAR) && OwnerSystem->GetMouseX() <= Coords[2]))
1323 && OwnerSystem->GetMouseY() >= CaptionCoords[1]
1324 && ((OwnerSystem->GetMouseY() <= CaptionCoords[3]) || ((Style & WS_NOTITLEBAR) && OwnerSystem->GetMouseY() <= Coords[2])))
1326 OwnerSystem->SetGraspedObject(
this, GST_MOUSE_LEFT_BUTTON);
1340 if (CloseHighlight) {
1345 if (HideHighlight) {
1347 Coords[3] = UnhiddenHeight;
1348 Style &= ~GS_HIDDEN;
1350 UnhiddenHeight = Coords[3];
1351 Coords[3] = Coords[1] + (CaptionCoords[3] - CaptionCoords[1]) + BorderSizes[1] + BorderSizes[3];
1366 HideHighlight =
false;
1367 CloseHighlight =
false;
1373 CloseCoords[0] += dx;
1374 CloseCoords[1] += dy;
1375 CloseCoords[2] += dx;
1376 CloseCoords[3] += dy;
1378 HideCoords[0] += dx;
1379 HideCoords[1] += dy;
1380 HideCoords[2] += dx;
1381 HideCoords[3] += dy;
1383 CaptionCoords[0] += dx;
1384 CaptionCoords[1] += dy;
1385 CaptionCoords[2] += dx;
1386 CaptionCoords[3] += dy;
1390 UnhiddenHeight += dy;
1395 for (i = 0; i < 8; i++) {
1407 gr_line(x1, y1, x2, y1, resize_mode);
1408 gr_line(x2, y1, x2, y2, resize_mode);
1409 gr_line(x2, y2, x1, y2, resize_mode);
1410 gr_line(x1, y2, x1, y1, resize_mode);
1438 IMG_DRAW(Coords[2] - w, Coords[1]);
1444 IMG_DRAW(Coords[0], Coords[3] - h);
1451 IMG_DRAW(Coords[2]-w, Coords[3] - h);
1458 gr_line(Coords[0] + BorderSizes[0], Coords[1], Coords[2] - BorderSizes[2], Coords[1],
GR_RESIZE_NONE);
1465 gr_line(Coords[0] + BorderSizes[0], Coords[3], Coords[2] - BorderSizes[2], Coords[3],
GR_RESIZE_NONE);
1473 gr_line(Coords[0], Coords[1] + BorderSizes[1], Coords[0], Coords[3] - BorderSizes[3],
GR_RESIZE_NONE);
1480 gr_line(Coords[2], Coords[1] + BorderSizes[1], Coords[2], Coords[3] - BorderSizes[3],
GR_RESIZE_NONE);
1484 if (!(Style & WS_NOTITLEBAR)) {
1490 draw_open_rect(Coords[0], Coords[1], Coords[2], CaptionCoords[3]);
1500 IMG_DRAW(CloseCoords[0], CloseCoords[1]);
1502 if (CloseHighlight) {
1518 IMG_DRAW(HideCoords[0], HideCoords[1]);
1520 if (HideHighlight) {
1544 while ( cgp && (cgp !=
END_OF_LIST(&Children)) ) {
1552 :
GUIObject(in_caption, x_coord,y_coord,x_width,y_width,in_style)
1554 Caption = in_caption;
1556 CloseHighlight =
false;
1557 HideHighlight =
false;
1569 :
GUIObject(in_caption, x_coord, y_coord, x_width, y_height, in_style)
1571 Caption = in_caption;
1573 function = in_function;
1587 Coords[2] = Coords[0] +
w;
1590 Coords[3] = Coords[1] +
h;
1595 Coords[2] = Coords[0] +
w;
1598 Coords[3] = Coords[1] +
h;
1630 half_x = Coords[0] +(((Coords[2]-Coords[0]) - half_x) / 2);
1631 half_y = Coords[1] +(((Coords[3]-Coords[1]) - half_y) / 2);
1638 OwnerSystem->SetActiveObject(
this);
1648 if (
function != NULL) {
1677 ShowChildren =
false;
1680 memset(Coords, 0,
sizeof(Coords));
1687 for (; cgp !=
END_OF_LIST(&Children); cgp = cgp_next) {
1698 void Tree::CalcItemsSize(
TreeItem *items,
int DrawData[4])
1707 int temp_largest = DrawData[1];
1711 if ((w + DrawData[0]) > temp_largest) {
1712 temp_largest = w + DrawData[0];
1720 tip->ShowThis =
false;
1722 tip->ShowThis =
true;
1726 if (tip->ShowThis) {
1727 if ((w + DrawData[0]) > DrawData[1]) {
1728 DrawData[1] = w + DrawData[0];
1731 tip->Coords[0] = Coords[0] + DrawData[0];
1732 tip->Coords[1] = Coords[1] + DrawData[2];
1733 tip->Coords[2] = Coords[0] + DrawData[0] +
w;
1734 tip->Coords[3] = Coords[1] + DrawData[2] +
h;
1738 if (
NOT_EMPTY(&tip->Children) && tip->ShowChildren) {
1741 CalcItemsSize((
TreeItem*)&tip->Children, DrawData);
1746 if (DrawData[3] || !tip->ShowThis) {
1747 tip->ShowThis =
false;
1748 tip->ShowChildren =
false;
1749 tip->Coords[0] = tip->Coords[1] = tip->Coords[2] = tip->Coords[3] = -1;
1762 CalcItemsSize(&Items, DrawData);
1768 if (!(Style & GS_NOAUTORESIZEY)) {
1770 if (Parent != NULL) {
1771 if(DrawData[2] >= Parent->ChildCoords[3]) {
1779 Tree::Tree(
const SCP_string &in_name,
int x_coord,
int y_coord,
void* in_associateditem,
int x_width,
int y_height,
int in_style)
1780 :
GUIObject(in_name, x_coord, y_coord, x_width, y_height, in_style)
1782 AssociatedItem = in_associateditem;
1784 SelectedItem = NULL;
1785 HighlightedItem = NULL;
1791 void Tree::DrawItems(
TreeItem *items)
1794 if (tip->ShowThis) {
1795 if (SelectedItem == tip) {
1797 }
else if (HighlightedItem == tip) {
1805 if (
NOT_EMPTY(&tip->Children) && tip->ShowChildren) {
1806 DrawItems((
TreeItem*)&tip->Children);
1815 if (
EMPTY(&Items)) {
1830 if (OwnerSystem->GetMouseX() >= tip->Coords[0]
1831 && OwnerSystem->GetMouseX() <= tip->Coords[2]
1832 && OwnerSystem->GetMouseY() >= tip->Coords[1]
1833 && OwnerSystem->GetMouseY() <= tip->Coords[3]) {
1840 }
else if (
NOT_EMPTY(&tip->Children) && tip->ShowChildren) {
1841 hti = HitTest((
TreeItem*)&tip->Children);
1853 HighlightedItem = HitTest(&Items);
1859 OwnerSystem->SetActiveObject(
this);
1865 OwnerSystem->SetActiveObject(
this);
1867 if (HighlightedItem != NULL) {
1868 SelectedItem = HighlightedItem;
1869 SelectedItem->ShowChildren = !SelectedItem->ShowChildren;
1870 if (
NOT_EMPTY(&SelectedItem->Children)) {
1873 if (SelectedItem->Function != NULL) {
1874 SelectedItem->Function(
this);
1881 void Tree::MoveTreeItems(
int dx,
int dy,
TreeItem *items)
1884 if (tip->ShowThis) {
1885 tip->Coords[0] += dx;
1886 tip->Coords[1] += dy;
1887 tip->Coords[2] += dx;
1888 tip->Coords[3] += dy;
1890 if (
NOT_EMPTY(&tip->Children) && tip->ShowChildren) {
1891 MoveTreeItems(dx, dy, (
TreeItem*)&tip->Children);
1899 MoveTreeItems(dx, dy, &Items);
1906 ni->Parent = parent;
1909 ni->DeleteData = in_delete_data;
1910 ni->Function = in_function;
1912 if (parent != NULL) {
1929 for (; cgp !=
END_OF_LIST(&Items); cgp = cgp_next) {
1940 width = Coords[2] - Coords[0];
1941 }
else if (Parent != NULL && (Parent->Style & GS_NOAUTORESIZEX)) {
1942 width = Parent->ChildCoords[2] - Coords[0];
1950 int longest_width = 0;
1952 for (
int i = 0;
i < NumLines;
i++) {
1954 if (width_test > longest_width) {
1955 longest_width = width_test;
1958 if (longest_width < width) {
1959 width = longest_width;
1963 if (Style & GS_NOAUTORESIZEY) {
1966 if (new_height < NumLines) {
1967 NumLines = new_height;
1971 if (Parent != NULL) {
1972 if (Coords[3] >= Parent->ChildCoords[3] && (Parent->Style & GS_NOAUTORESIZEY)) {
1973 Coords[3] = Coords[1] + (Parent->ChildCoords[3] - Coords[1]);
1979 if (!(Style & GS_NOAUTORESIZEX)) {
1980 Coords[2] = Coords[0] +
width;
1984 ChildCoords[0] = Coords[0] + 1;
1985 ChildCoords[1] = Coords[1] + 1;
1986 ChildCoords[2] = Coords[2] - 1;
1987 ChildCoords[3] = Coords[3] - 1;
1989 ChildCoords[0] = Coords[0];
1990 ChildCoords[1] = Coords[1];
1991 ChildCoords[2] = Coords[2];
1992 ChildCoords[3] = Coords[3];
2003 OwnerSystem->SetActiveObject(
this);
2005 CursorPos = Content.size();
2014 if (OwnerSystem->GetActiveObject() !=
this) {
2025 if (!Content.length()) {
2031 for (
int i = 0;
i < NumLines;
i++) {
2032 gr_string(ChildCoords[0], ChildCoords[1] + (
i*font_height), Content.substr(LineStartPoints[
i] - Content.c_str(), LineLengths[
i]).c_str(),
GR_RESIZE_NONE);
2044 switch(OwnerSystem->GetKeyPressed()) {
2046 Content = Content.substr(0, Content.length() - 1);
2052 OwnerSystem->SetActiveObject(Parent);
2061 OwnerSystem->SetActiveObject(Parent);
2071 if (iscntrl(symbol)) {
2074 if (!isdigit(symbol) && symbol !=
'-') {
2078 if (!isdigit(symbol) && symbol !=
'.' && symbol !=
'-') {
2082 if (!isdigit(symbol)) {
2085 }
else if (!isalnum(symbol) && symbol !=
' ') {
2090 Content += char(symbol);
2101 :
GUIObject(in_name, x_coord, y_coord, x_width, y_height, in_style)
2103 Content = in_content;
2112 Content = in_content;
2127 sprintf(buf,
"%f", the_float);
2141 Assert(min_value < max_value);
2157 void Text::SetSaveLoc(
short int *sint_ptr,
int save_method,
short int max_value,
short int min_value)
2159 Assert(sint_ptr != NULL);
2160 Assert(min_value < max_value);
2179 Assert(min_value < max_value);
2242 Assert(min_value < max_value);
2265 int the_int = atoi(Content.c_str());
2266 if (the_int <= SaveMax && the_int >=
SaveMin) {
2271 short the_sint = (short)atoi(Content.c_str());
2272 if (the_sint <= SaveMax && the_sint >=
SaveMin) {
2277 float the_float = (
float)atof(Content.c_str());
2278 if (the_float <= flSaveMax && the_float >=
flSaveMin) {
2283 size_t len = Content.length();
2306 int the_int = atoi(Content.c_str());
2307 if (the_int <= SaveMax && the_int >=
SaveMin) {
2328 }
else if (SaveType & T_ST_CHAR) {
2333 Warning(
LOCATION,
"Unknown type (or no type) given in Text::Load() - nothing happened.");
2340 :
GUIObject(in_label, x_coord, y_coord, x_width, y_height, in_style)
2344 function = in_function;
2347 HighlightStatus = 0;
2366 CheckCoords[0] = Coords[0];
2367 CheckCoords[1] = Coords[1];
2368 CheckCoords[2] = Coords[0] +
w;
2369 CheckCoords[3] = Coords[1] +
h;
2372 Coords[2] = Coords[0] + tw;
2375 if (!(Style & GS_NOAUTORESIZEY)) {
2376 Coords[3] = Coords[1] + th;
2384 CheckCoords[0] += dx;
2385 CheckCoords[2] += dx;
2386 CheckCoords[1] += dy;
2387 CheckCoords[3] += dy;
2392 if (HighlightStatus == 1) {
2394 }
else if (HighlightStatus == 2) {
2402 if ( (IsChecked && ((FlagPtr == NULL) && (BoolFlagPtr == NULL)))
2403 || ((FlagPtr != NULL) && ((*FlagPtr) &
Flag))
2404 || ((BoolFlagPtr != NULL) && (*BoolFlagPtr)) ) {
2414 if ( (OwnerSystem->GetMouseX() >= CheckCoords[0])
2415 && (OwnerSystem->GetMouseX() <= CheckCoords[2])
2416 && (OwnerSystem->GetMouseY() >= CheckCoords[1])
2417 && (OwnerSystem->GetMouseY() <= CheckCoords[3]) ) {
2418 HighlightStatus = 1;
2426 OwnerSystem->SetActiveObject(
this);
2428 if ( (OwnerSystem->GetMouseX() >= CheckCoords[0])
2429 && (OwnerSystem->GetMouseX() <= CheckCoords[2])
2430 && (OwnerSystem->GetMouseY() >= CheckCoords[1])
2431 && (OwnerSystem->GetMouseY() <= CheckCoords[3]) ) {
2432 HighlightStatus = 2;
2440 if ( (OwnerSystem->GetMouseX() >= CheckCoords[0])
2441 && (OwnerSystem->GetMouseX() <= CheckCoords[2])
2442 && (OwnerSystem->GetMouseY() >= CheckCoords[1])
2443 && (OwnerSystem->GetMouseY() <= CheckCoords[3]) ) {
2444 HighlightStatus = 1;
2446 if (
function != NULL) {
2450 if (FlagPtr != NULL) {
2451 if ( !(*FlagPtr &
Flag) ) {
2458 }
else if (BoolFlagPtr != NULL) {
2459 *BoolFlagPtr = !(*BoolFlagPtr);
2460 IsChecked = *BoolFlagPtr;
2462 IsChecked = !IsChecked;
2471 HighlightStatus = 0;
2478 :
GUIObject(in_name, x_coord, y_coord, x_width, y_width, in_style)
2494 if (ImageHandle == -1) {
2500 ElapsedTime += frametime;
2502 ElapsedTime -= frametime;
2505 Progress = ElapsedTime/TotalTime;
2508 int CurrentFrame =
fl2i(Progress * TotalFrames);
2509 if (Progress > 1.0
f) {
2512 CurrentFrame = TotalFrames;
2520 CurrentFrame = TotalFrames;
2523 }
else if (Progress < 1.0
f) {
2530 CurrentFrame = TotalFrames;
2554 if (in_imagename.size()) {
2555 ImageHandle =
IMG_LOAD_ANIM(in_imagename.c_str(), &TotalFrames, &FPS);
2556 TotalTime = (
float) (TotalFrames/FPS);
2558 ImageHandle =
IMG_LOAD(in_imagename.c_str());
int OnFrame(float frametime, int *unused_queue)
void SetSaveLoc(int *ptr, int save_method, int max_value=INT_MAX, int min_value=INT_MIN)
void DeleteChildren(GUIObject *exception=NULL)
int DoMouseDown(float frametime)
GUIScreen * PushScreen(GUIScreen *csp)
void parse_advance(int s)
int DoKeyPress(float frametime)
virtual int DoKeyPress(float frametime)
int check_for_string(const char *pstr)
GLfloat GLfloat GLfloat GLfloat h
#define GST_MOUSE_LEFT_BUTTON
void AddLine(const SCP_string &in_line)
void gr_opengl_shade(int x, int y, int w, int h, int resize_mode)
#define MOUSE_LEFT_BUTTON
int GetCIECoords(int id, int *x, int *y)
int DoMouseDown(float frametime)
int keypad_to_ascii(int c)
Checkbox(const SCP_string &in_label, int x_coord, int y_coord, void(*in_function)(Checkbox *caller)=NULL, int x_width=-1, int y_height=DEFAULT_BUTTON_HEIGHT, int in_style=0)
Tree(const SCP_string &in_name, int x_coord, int y_coord, void *in_associateditem=NULL, int x_width=-1, int y_width=-1, int in_style=0)
#define PT_STOPPED_REVERSE
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
bitmap_2d_list screen_rect
void Parse(char *tag, int in_type)
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
#define list_append(head, elem)
#define MOUSE_MIDDLE_BUTTON
int OnFrame(float frametime, bool doevents, bool clearandflip)
#define GST_KEYBOARD_STATUS
GUIObject * Add(GUIObject *new_gauge)
#define END_OF_LIST(head)
virtual int DoMouseOver(float frametime)
GUIObject * GetGraspedObject()
int mouse_get_pos(int *xpos, int *ypos)
void gr_set_color_fast(color *dst)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
#define list_move_append(head, elem)
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
int key_to_ascii(int keycode)
GLenum GLuint GLenum GLsizei const GLchar * buf
virtual void DoMove(int dx, int dy)
void SetGraspedObject(GUIObject *cgp, int button)
int DoMouseOver(float frametime)
int DoMouseUp(float frametime)
void SetActiveObject(GUIObject *cgp)
#define GST_KEYBOARD_SHIFT
void DoDraw(float frametime)
int DoMouseDown(float frametime)
#define GR_ALPHABLEND_FILTER
virtual int DoMouseUp(float frametime)
GUIScreen(const SCP_string &in_Name="")
Window(const SCP_string &in_caption, int x_coord, int y_coord, int x_width=-1, int y_height=-1, int in_style=0)
GUIObject(const SCP_string &in_Name="", int x_coord=0, int y_coord=0, int x_width=-1, int y_height=-1, int in_style=0)
#define IMG_INFO(ha, w, h)
void Play(bool in_isreversed)
void draw_open_rect(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_NONE)
int DoMouseOver(float frametime)
void stuff_string(char *outstr, int type, int len, char *terminators)
#define PT_PLAYING_REVERSE
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
#define IMG_HANDLE_SET_FRAME(dh, h, f)
#define IMG_HANDLE_SET_INVALID(h)
#define GST_MOUSE_RIGHT_BUTTON
int required_string(const char *pstr)
void OnMove(int dx, int dy)
int GetObjectCoords(int *x, int *y, int *w, int *h)
#define GSOF_SOMETHINGPRESSED
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char)
int optional_string(const char *pstr)
int DoMouseOver(float frametime)
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
void DoDraw(float frametime)
void SetText(const SCP_string &in_content)
int OnFrame(float frametime, bool doevents)
#define IMG_LOAD_ANIM(f, n, fps)
void DoMove(int dx, int dy)
GLint GLint GLint GLint GLint x
TreeItem * AddItem(TreeItem *parent, const SCP_string &in_name, int in_data=0, bool in_delete_data=true, void(*in_function)(Tree *caller)=NULL)
void SetSaveStringAlloc(char **ptr, int save_method, int mem_flags, uint max_len=UINT_MAX, uint min_len=0)
GUIObject * AddChild(GUIObject *cgp)
void OnDraw(float frametime)
ImageAnim(const SCP_string &in_name, const SCP_string &in_imagename, int x_coord, int y_coord, int x_width=-1, int y_width=-1, int in_style=0)
int GetCoords(int *x, int *y)
void reset_parse(char *text)
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
int DoMouseOut(float frametime)
int GetCoords(int id, int *x, int *y)
int DoMouseOut(float frametime)
ScreenClassInfoEntry * GetClassInfo()
int stuff_int_list(int *ilp, int max_ints, int lookup_type)
color Color_text_selected
#define MOUSE_RIGHT_BUTTON
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
#define TI_INITIAL_INDENT_VERTICAL
virtual int DoMouseDown(float frametime)
virtual void DoDraw(float frametime)
#define GST_KEYBOARD_CTRL
GLubyte GLubyte GLubyte GLubyte w
void gr_bitmap_list(bitmap_2d_list *list, int n_bm, int resize_mode)
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
void DoDraw(float frametime)
#define TI_INDENT_PER_LEVEL
int DoMouseDown(float frametime)
void DoMove(int dx, int dy)
int DoMouseUp(float frametime)
int DoMouseUp(float frametime)
ScreenClassInfoEntry * GetScreenClassInfo(const SCP_string &screen_name)
void DoDraw(float frametime)
#define GST_KEYBOARD_KEYPRESS
#define IMG_HANDLE_IS_INVALID(h)
virtual int DoMouseOut(float frametime)
#define GSOF_NOTHINGPRESSED
#define TI_INITIAL_INDENT
#define GR_BITBLT_MODE_NORMAL
void PullScreen(GUIScreen *in_screen)
#define GST_MOUSE_MIDDLE_BUTTON
virtual int DoKeyState(float frametime)
void DeleteObject(GUIObject *dgp)
void gr_create_shader(shader *shade, ubyte r, ubyte g, ubyte b, ubyte c)
#define IMG_HANDLE_IS_VALID(h)
void ParseClassInfo(char *section)
void DoDraw(float frametime)
void SetPosition(int x, int y)
void gr_set_shader(shader *shade)
ObjectClassInfoEntry * GetObjectClassInfo(GUIObject *cgp)
int GetCIEImageHandle(int id, int handleid=0)
void SetImage(const SCP_string &in_imagename)
virtual int DoFrame(float frametime)
Text(const SCP_string &in_name, const SCP_string &in_content, int x_coord, int y_coord, int x_width=-1, int y_width=-1, int in_style=0)
void DoMove(int dx, int dy)
int GetImageHandle(int id, int handle_num)