void ARX_QuickLoad() { SavegameHandle save = savegames.quickload(); if(save == SavegameHandle()) { // No saves found! return; } ARX_LoadGame(savegames[save]); }
void TextWidget::RenderMouseOver() { pMenuCursor->SetMouseOver(); GRenderer->SetRenderState(Renderer::AlphaBlending, true); GRenderer->SetBlendFunc(BlendOne, BlendOne); FontRenderText(m_font, m_rect, m_text, lColorHighlight); GRenderer->SetRenderState(Renderer::AlphaBlending, false); switch(m_id) { case BUTTON_MENUEDITQUEST_LOAD: case BUTTON_MENUEDITQUEST_SAVEINFO: { if(m_savegame == SavegameHandle()) { g_thumbnailCursor.clear(); break; } const res::path & image = savegames[m_savegame.handleData()].thumbnail; if(!image.empty()) { TextureContainer * t = TextureContainer::LoadUI(image, TextureContainer::NoColorKey); if(t != g_thumbnailCursor.m_loadTexture) { delete g_thumbnailCursor.m_loadTexture; g_thumbnailCursor.m_loadTexture = t; } g_thumbnailCursor.m_renderTexture = g_thumbnailCursor.m_loadTexture; } break; } default: { g_thumbnailCursor.clear(); break; } } }
void init() { { ButtonWidget * cb = new ButtonWidget(Vec2i(RATIO_X(10), 0), "graph/interface/icons/menu_main_save"); cb->SetCheckOff(); addCenter(cb, true); } std::string quicksaveName = getLocalised("system_menus_main_quickloadsave", "Quicksave"); size_t quicksaveNum = 0; // Show quicksaves. for(size_t i = 0; i < savegames.size(); i++) { const SaveGame & save = savegames[i]; if(!save.quicksave) { continue; } std::ostringstream text; text << quicksaveName << ' ' << ++quicksaveNum << " " << save.time; TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text.str(), Vec2i(RATIO_X(20), 0.f)); e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM; e->setColor(Color::grayb(127)); e->SetCheckOff(); e->m_savegame = SavegameHandle(i); addCenter(e); } // Show regular saves. for(size_t i = 0; i < savegames.size(); i++) { const SaveGame & save = savegames[i]; if(save.quicksave) { continue; } std::string text = save.name + " " + save.time; TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text, Vec2i(RATIO_X(20), 0.f)); e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM; e->m_savegame = SavegameHandle(i); addCenter(e); } for(size_t i = savegames.size(); i <= 15; i++) { std::ostringstream text; text << '-' << std::setfill('0') << std::setw(4) << i << '-'; TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_SAVEINFO, hFontControls, text.str(), Vec2i(RATIO_X(20), 0)); e->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM; e->m_savegame = SavegameHandle::Invalid; addCenter(e); } { TextWidget * me01 = new TextWidget(BUTTON_INVALID, hFontControls, " ", Vec2i(RATIO_X(20), 0)); me01->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM; me01->m_savegame = SavegameHandle::Invalid; me01->SetCheckOff(); addCenter(me01); } { ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 420)), "graph/interface/menus/back"); cb->m_targetMenu = EDIT_QUEST; cb->SetShortCut(Keyboard::Key_Escape); add(cb); } }
void init() { { ButtonWidget * cb = new ButtonWidget(Vec2i(0, 0), "graph/interface/icons/menu_main_load"); cb->SetCheckOff(); addCenter(cb, true); } std::string quicksaveName = getLocalised("system_menus_main_quickloadsave", "Quicksave"); // TODO make this list scrollable // TODO align the date part to the right! { size_t quicksaveNum = 0; // Show quicksaves. for(size_t i = 0; i < savegames.size(); i++) { const SaveGame & save = savegames[i]; if(!save.quicksave) { continue; } std::ostringstream text; text << quicksaveName << ' ' << ++quicksaveNum << " " << save.time; TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_LOAD, hFontControls, text.str(), Vec2i(RATIO_X(20), 0)); e->m_savegame = SavegameHandle(i); addCenter(e); } // Show regular saves. for(size_t i = 0; i < savegames.size(); i++) { const SaveGame & save = savegames[i]; if(save.quicksave) { continue; } std::string text = save.name + " " + save.time; TextWidget * e = new TextWidget(BUTTON_MENUEDITQUEST_LOAD, hFontControls, text, Vec2i(RATIO_X(20), 0)); e->m_savegame = SavegameHandle(i); addCenter(e); } { TextWidget * confirm = new TextWidget(BUTTON_INVALID, hFontControls, " ", Vec2i(RATIO_X(20), 0)); confirm->m_targetMenu = EDIT_QUEST_SAVE_CONFIRM; confirm->SetCheckOff(); confirm->m_savegame = SavegameHandle::Invalid; addCenter(confirm); } // Delete button { std::string szMenuText = getLocalised("system_menus_main_editquest_delete"); szMenuText += " "; TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_DELETE_CONFIRM, hFontMenu, szMenuText, Vec2i(0, 0)); me->m_targetMenu = EDIT_QUEST_LOAD; me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(42))); me->SetCheckOff(); me->lOldColor = me->lColor; me->lColor = Color::grayb(127); add(me); pDeleteConfirm = me; } // Load button { std::string szMenuText = getLocalised("system_menus_main_editquest_load"); szMenuText += " "; TextWidget * me = new TextWidget(BUTTON_MENUEDITQUEST_LOAD_CONFIRM, hFontMenu, szMenuText, Vec2i(0, 0)); me->m_targetMenu = MAIN; me->SetPos(Vec2i(RATIO_X(m_size.x-10)-me->m_rect.width(), RATIO_Y(380) + RATIO_Y(40))); me->SetCheckOff(); me->lOldColor = me->lColor; me->lColor = Color::grayb(127); add(me); pLoadConfirm = me; } // Back button { ButtonWidget * cb = new ButtonWidget(RATIO_2(Vec2i(20, 420)), "graph/interface/menus/back"); cb->clicked = boost::bind(&LoadMenuPage::onClickBack, this); cb->m_targetMenu = EDIT_QUEST; cb->SetShortCut(Keyboard::Key_Escape); add(cb); } } }
// true: block les zones de checks bool TextWidget::OnMouseClick() { if(!enabled) { return false; } if(clicked) { clicked(this); } switch(eState) { case EDIT: eState=EDIT_TIME; return true; case GETTOUCH: eState=GETTOUCH_TIME; lOldColor=lColorHighlight; return true; default: break; } switch(m_id) { // MENULOADQUEST case BUTTON_MENUEDITQUEST_LOAD: { if(pWindowMenu) { pLoadConfirm->SetCheckOn(); pLoadConfirm->lColor = pLoadConfirm->lOldColor; pDeleteConfirm->SetCheckOn(); pDeleteConfirm->lColor = pDeleteConfirm->lOldColor; for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) { MenuPage * page = pWindowMenu->m_pages[i]; if(page->eMenuState == EDIT_QUEST_LOAD) { page->m_savegame = m_savegame; for(size_t j = 0; j < page->m_children.m_widgets.size(); j++) { Widget * widget = page->m_children.m_widgets[j]; if(widget->m_id == BUTTON_MENUEDITQUEST_LOAD) { ((TextWidget *)widget)->bSelected = false; } } bSelected = true; } } } } break; case BUTTON_MENUEDITQUEST_LOAD_CONFIRM: { if(pWindowMenu) { for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) { MenuPage * page = pWindowMenu->m_pages[i]; if(page->eMenuState == EDIT_QUEST_LOAD) { m_savegame = page->m_savegame; if(m_savegame != SavegameHandle()) { m_targetMenu = MAIN; GRenderer->Clear(Renderer::DepthBuffer); ARXMenu_LoadQuest(m_savegame); bNoMenu=true; if(pTextManage) { pTextManage->Clear(); } break; } } } pLoadConfirm->SetCheckOff(); pLoadConfirm->lColor = Color::grayb(127); pDeleteConfirm->SetCheckOff(); pDeleteConfirm->lColor = Color::grayb(127); } } break; // MENUSAVEQUEST case BUTTON_MENUEDITQUEST_SAVE: { if(pWindowMenu) for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) { MenuPage * page = pWindowMenu->m_pages[i]; if(page->eMenuState == EDIT_QUEST_SAVE_CONFIRM) { page->m_savegame = m_savegame; TextWidget * me = (TextWidget *) page->m_children.m_widgets[1]; if(me) { m_targetMenu = MAIN; ARXMenu_SaveQuest(me->m_text, me->m_savegame); break; } } } } break; // Delete save from the load menu case BUTTON_MENUEDITQUEST_DELETE_CONFIRM: { if(pWindowMenu) { for(size_t i = 0 ; i < pWindowMenu->m_pages.size(); i++) { MenuPage * page = pWindowMenu->m_pages[i]; if(page->eMenuState == EDIT_QUEST_LOAD) { m_savegame = page->m_savegame; if(m_savegame != SavegameHandle()) { m_targetMenu = EDIT_QUEST_LOAD; mainMenu->bReInitAll = true; savegames.remove(m_savegame); break; } } } } pLoadConfirm->SetCheckOff(); pLoadConfirm->lColor = Color::grayb(127); pDeleteConfirm->SetCheckOff(); pDeleteConfirm->lColor = Color::grayb(127); break; } // Delete save from the save menu case BUTTON_MENUEDITQUEST_DELETE: { if(pWindowMenu) { for(size_t i = 0 ; i < pWindowMenu->m_pages.size(); i++) { MenuPage * page = pWindowMenu->m_pages[i]; if(page->eMenuState == EDIT_QUEST_SAVE_CONFIRM) { page->m_savegame = m_savegame; TextWidget * me = (TextWidget *) page->m_children.m_widgets[1]; if(me) { m_targetMenu = EDIT_QUEST_SAVE; mainMenu->bReInitAll = true; savegames.remove(me->m_savegame); break; } } } } break; } default: break; } if(m_targetMenu == EDIT_QUEST_SAVE_CONFIRM) { for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) { MenuPage * page = pWindowMenu->m_pages[i]; if(page->eMenuState == m_targetMenu) { page->m_savegame = m_savegame; TextWidget * me = (TextWidget *) page->m_children.m_widgets[1]; if(me) { me->m_savegame = m_savegame; if(m_savegame != SavegameHandle()) { me->SetText(savegames[m_savegame.handleData()].name); pDeleteButton->lColor = pDeleteButton->lOldColor; pDeleteButton->SetCheckOn(); } else { pDeleteButton->lColor = Color::grayb(127); pDeleteButton->SetCheckOff(); me->SetText(getLocalised("system_menu_editquest_newsavegame")); } page->AlignElementCenter(me); } } } } ARX_SOUND_PlayMenu(SND_MENU_CLICK); return false; }