void AGOL_Settings::ReplaceWadDirSelectorOk(AG_Event *event) { AG_TlistItem *selitem = AG_TlistSelectedItem(WadDirList); char *waddir = AG_STRING(2); if((selitem && strlen(selitem->text) > 0) && (waddir && strlen(waddir) > 0 && !IsWadDirDuplicate(waddir))) { list<string>::iterator i; // Look for the selected directory in the list for(i = WadDirs.begin(); i != WadDirs.end(); ++i) if(*i == selitem->text) { // Replace the item with the new path *i = waddir; break; } } DeleteEventHandler(DirSelOkHandler); delete DirSel; DirSel = NULL; }
/* Must be invoked from main event/rendering context. */ static void SetColor(AG_Event *event) { AG_Tlist *tl = AG_PTR(1); AG_TlistItem *it = AG_TlistSelectedItem(tl); if (it != NULL && it->p1 == &agColors[BG_COLOR]) { Uint8 r, g, b; AG_ColorsGetRGB(BG_COLOR, &r, &g, &b); AG_ColorsSetRGB(BG_COLOR, r, g, b); } }
static void SelectedItem(AG_Event *event) { AG_Tlist *tl = AG_SELF(); AG_Combo *com = AG_PTR(1); AG_TlistItem *ti; AG_ObjectLock(tl); if ((ti = AG_TlistSelectedItem(tl)) != NULL) { AG_TextboxSetString(com->tbox, ti->text); AG_PostEvent(NULL, com, "combo-selected", "%p", ti); } AG_ObjectUnlock(tl); Collapse(com); }
void AGOL_Settings::OnReplaceWadDir(AG_Event *event) { if(DirSel) return; if(AG_TlistSelectedItem(WadDirList) == NULL) return; // Create and display a new directory selector dialog DirSel = new AGOL_DirSelector("Select a folder containing WAD files"); // Register and set the OK and Cancel events DirSelOkHandler = RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::ReplaceWadDirSelectorOk); DirSel->SetOkAction(DirSelOkHandler); DirSelCancelHandler = RegisterEventHandler((EVENT_FUNC_PTR)&AGOL_Settings::DirectorySelectorCancel); DirSel->SetCancelAction(DirSelCancelHandler); }
static void SelectedItem(AG_Event *event) { AG_Tlist *tl = AG_SELF(); AG_UCombo *com = AG_PTR(1); AG_TlistItem *it; AG_ObjectLock(com); AG_ObjectLock(tl); if ((it = AG_TlistSelectedItem(tl)) != NULL) { it->selected++; AG_ButtonTextS(com->button, it->text); AG_PostEvent(NULL, com, "ucombo-selected", "%p", it); } Collapse(com); AG_ObjectUnlock(tl); AG_ObjectUnlock(com); }
void AGOL_Settings::OnDeleteWadDir(AG_Event *event) { AG_TlistItem *selitem = AG_TlistSelectedItem(WadDirList); if(selitem && strlen(selitem->text) > 0) { list<string>::iterator i; // Look for the selected directory in the list for(i = WadDirs.begin(); i != WadDirs.end(); ++i) if(*i == selitem->text) { // Delete the list item WadDirs.erase(i); break; } } }
void AGOL_Settings::OnMoveWadDirDown(AG_Event *event) { AG_TlistItem *selitem = AG_TlistSelectedItem(WadDirList); if(selitem && strlen(selitem->text) > 0) { list<string>::iterator i = WadDirs.begin(); list<string>::iterator prev = WadDirs.begin(); // Look for the selected directory in the list for(++i; i != WadDirs.end(); ++i) { if(*prev == selitem->text) { // Swap the item with the one after it iter_swap(prev, i); break; } prev = i; } } }
void AGOL_Settings::OnMoveWadDirUp(AG_Event *event) { AG_TlistItem *selitem = AG_TlistSelectedItem(WadDirList); if(selitem && strlen(selitem->text) > 0) { list<string>::iterator i; list<string>::iterator prev; // Look for the selected directory in the list for(i = WadDirs.begin(); i != WadDirs.end(); ++i) { if(*i == selitem->text) { // Swap the item with the one before it if(i != WadDirs.begin()) iter_swap(i, prev); break; } prev = i; } } }