//----------------------------------------------------------------------------- void ServerNetApplyManager::closeAllClient() { closeAll(mClientDriver); }
DataManager::~DataManager() { closeAll(); }
void GLTDisp::mousePressEvent(QMouseEvent *event) { if (lsStatus == LS_NONE) { if (swEvent->isFocus(SubWindow::FOCUS_MORE)) { moreInfo(); return; } if (focusReset) { cReset(); return; } GLWidget::mousePressEvent(event); return; } if (lsStatus != LS_OPEN || !subWin) return; subWin->checkFocus(event->x(), event->y()); if (subWin->isFocus(SubWindow::FOCUS_CLOSE)) { closeAll(); return; } if (subWin->isFocus(SubWindow::FOCUS_MORE)) { if (subWin->getType() == SubWindow::SW_TRACK) { if (twTrk && twTrk->isVisible()) twTrk->close(); else { twTrk = openTEWidget(twTrk); twTrk->setText(InfoText::TrackInfo(currEvent, subWin->getID())); twTrk->show(); } } else if (subWin->getType() == SubWindow::SW_LADDER) { if (twLad && twLad->isVisible()) twLad->close(); else { twLad = openTEWidget(twLad); twLad->setText(InfoText::LadderInfo(currEvent, subWin->getID())); twLad->show(); } } return; } if (subWin->isFocus(SubWindow::FOCUS_OPT)) { subWin->procMpress(); update(); return; } if (!subWin->isFocus(SubWindow::FOCUS_DOBJ)) return; if (subWin->getType() == SubWindow::SW_LADDER) { if (subWin->getDobjType() == SubWindow::DOBJ_CLS) emit drawCluster(subWin->getDobjID()); else if (subWin->getDobjType() >= SubWindow::DOBJ_TRK) { int tid = subWin->getDobjType()/SubWindow::DOBJ_TRK-1; TrTrackR *trk = currEvent->pTrTrack(tid); if (trk) { delete subWin; subWin = new SWTrack(currEvent, tid); aStep = 0; if (lsNstep > 0) lsStatus = LS_AOPEN; else { lsStatus = LS_OPEN; update(); } } } } else if (subWin->getType() == SubWindow::SW_TRACK) { int tkid = 0; if (subWin->getDobjType() == SubWindow::DOBJ_HIT) { int hid = ((SWTrack *)subWin)->getFocusHid(); TrTrackR *trk = currEvent->pTrTrack(subWin->getID()); TrRecHitR *hit = trk->GetHit(hid); if (hit) tkid = hit->GetTkId(); } else if (subWin->getDobjType() == SubWindow::DOBJ_LAD) tkid = subWin->getDobjID(); if (tkid != 0) { delete subWin; subWin = new SWLadder(currEvent, tkid); aStep = 0; if (lsNstep > 0) lsStatus = LS_AOPEN; else { lsStatus = LS_OPEN; update(); } } } }
Subprocess::~Subprocess() { CHECK_NE(returnCode_.state(), ProcessReturnCode::RUNNING) << "Subprocess destroyed without reaping child"; closeAll(); }
SFtpConnectionCache::~SFtpConnectionCache() { closeAll(); libssh2_exit(); }
XmlOutput::~XmlOutput() { closeAll(); }
CWizDatabaseManager::~CWizDatabaseManager() { m_instance = 0; closeAll(); }
MenuManager::MenuManager(PowerManager *_powers, StatBlock *_stats, CampaignManager *_camp, ItemManager *_items) { powers = _powers; stats = _stats; camp = _camp; items = _items; loadIcons(); hp = new MenuStatBar("hp"); menus.push_back(hp); // menus[0] mp = new MenuStatBar("mp"); menus.push_back(mp); // menus[1] xp = new MenuStatBar("xp"); menus.push_back(xp); // menus[2] effects = new MenuActiveEffects(icons); menus.push_back(effects); // menus[3] hudlog = new MenuHUDLog(); menus.push_back(hudlog); // menus[4] act = new MenuActionBar(powers, stats, icons); menus.push_back(act); // menus[5] enemy = new MenuEnemy(); menus.push_back(enemy); // menus[6] vendor = new MenuVendor(items, stats); menus.push_back(vendor); // menus[7] talker = new MenuTalker(camp); menus.push_back(talker); // menus[8] exit = new MenuExit(); menus.push_back(exit); // menus[9] mini = new MenuMiniMap(); menus.push_back(mini); // menus[10] chr = new MenuCharacter(stats); menus.push_back(chr); // menus[11] inv = new MenuInventory(items, stats, powers); menus.push_back(inv); // menus[12] pow = new MenuPowers(stats, powers, icons); menus.push_back(pow); // menus[13] log = new MenuLog(); menus.push_back(log); // menus[14] stash = new MenuStash(items, stats); menus.push_back(stash); // menus[15] tip = new WidgetTooltip(); // Load the menu positions and alignments from menus/menus.txt std::string align; FileParser infile; if (infile.open(mods->locate("menus/menus.txt"))) { while (infile.next()) { infile.val = infile.val + ','; int x = eatFirstInt(infile.val, ','); int y = eatFirstInt(infile.val, ','); int w = eatFirstInt(infile.val, ','); int h = eatFirstInt(infile.val, ','); align = eatFirstString(infile.val, ','); int menu_index = -1; if (infile.key == "hp") menu_index = 0; else if (infile.key == "mp") menu_index = 1; else if (infile.key == "xp") menu_index = 2; else if (infile.key == "effects") menu_index = 3; else if (infile.key == "hudlog") menu_index = 4; else if (infile.key == "actionbar") menu_index = 5; else if (infile.key == "enemy") menu_index = 6; else if (infile.key == "vendor") menu_index = 7; else if (infile.key == "talker") menu_index = 8; else if (infile.key == "exit") menu_index = 9; else if (infile.key == "minimap") menu_index = 10; else if (infile.key == "character") menu_index = 11; else if (infile.key == "inventory") menu_index = 12; else if (infile.key == "powers") menu_index = 13; else if (infile.key == "log") menu_index = 14; else if (infile.key == "stash") menu_index = 15; if (menu_index != -1) { menus[menu_index]->window_area.x = x; menus[menu_index]->window_area.y = y; menus[menu_index]->window_area.w = w; menus[menu_index]->window_area.h = h; menus[menu_index]->alignment = align; menus[menu_index]->align(); } } infile.close(); } else fprintf(stderr, "Unable to open menus/menus.txt!\n"); // Some menus need to be updated to apply their new dimensions act->update(); vendor->update(); vendor->buyback_stock.init(NPC_VENDOR_MAX_STOCK, items); talker->update(); exit->update(); chr->update(); inv->update(); pow->update(); log->update(); stash->update(); pause = false; dragging = false; drag_stack.item = 0; drag_stack.quantity = 0; drag_power = 0; drag_src = 0; drop_stack.item = 0; drop_stack.quantity = 0; loadSounds(); done = false; closeAll(false); // make sure all togglable menus start closed }
ofxKinectContext::~ofxKinectContext() { closeAll(); clear(); }
int main(int argc, char *argv[]) { int argn = argc; char *in = NULL; char *out = NULL; char *password = NULL; bool decrypt = false; bool verbose = false; bool overwrite = false; bool longrand = false; char inBuff = 0; char outBuff = 0; char place = 0; int passchar = 0; int loopn = 0; printf(MSG_SPASH); if(argc <= 1) { printf("%s%s", MSG_HELP, MSG_DONE); return err_noargs; } while((argn--) > 1) { if(!strcmp(argv[argn], ARG_HELP)) { printf("%s%s", MSG_HELP, MSG_DONE); return err_helpGiven; } else if(!strcmp(argv[argn - 1], ARG_IN)) { in = argv[argn]; } else if(!strcmp(argv[argn - 1], ARG_PASS)) { password = argv[argn]; } else if(!strcmp(argv[argn - 1], ARG_OUT)) { out = argv[argn]; } else if(!strcmp(argv[argn], ARG_DECRYPT)) { decrypt = true; } else if(!strcmp(argv[argn], ARG_VERBOSE)) { verbose = true; } else if(!strcmp(argv[argn], ARG_OVERWRITE)) { overwrite = true; } else if(!strcmp(argv[argn], ARG_LONGRAND)) { longrand = true; } } if(in == NULL) { printf("%s%s%s", MSG_NOIN, MSG_HELP, MSG_DONE); return err_noin; } if(password == NULL) { printf(MSG_GIVEPASS); password = fmakes(stdin); } if(!(password = strToBase8(password))) { printf("%s%s", MSG_ALLOCERR, MSG_DONE); return err_alloc; } if(verbose == true) printf("%s%s\n", MSG_BASE8EQU, password); if(out == NULL) { out = calloc( strlen(in) + strlen(FILEEXT) + sizeof(char), sizeof(char)); if(out == NULL) { printf("%s%s", MSG_ALLOCERR, MSG_DONE); return err_alloc; } strcat(out, in); strcat(out, FILEEXT); } if(!strcmp(out, in)) { printf("%s%s", MSG_CANNOTWTI, MSG_DONE); return 0; } if(!(inFile = fopen(in, "rb"))) { printf("%s%s", MSG_INNOTREAL, MSG_DONE); return err_innotreal; } if((outFile = fopen(out, "rb")) && overwrite == false) { printf(MSG_OUTEXISTS); scanf("%c", &overwrite); if(overwrite != 'y' && overwrite != 'Y') { printf("%s%s", MSG_WILLNOT, MSG_DONE); return err_willnot; } } if(!(outFile = fopen(out, "wb"))) { printf("%s%s", MSG_OUTCANT, MSG_DONE); return err_outcant; } fseek(inFile, 0, SEEK_SET); fseek(outFile, 0, SEEK_SET); if(decrypt == true) { printf("%s%s%s\n", in, MSG_TOD, out); while(!feof(inFile)) { if(fread(&inBuff, sizeof(inBuff), 1, inFile) != 1 && !feof(inFile)) { printf("%s%s", MSG_FREAD, MSG_DONE); closeAll(); return err_fread; } place = power2(loopn); if(getBit(inBuff, *(password + passchar) - '0')) outBuff += place; passchar ++; if(!(*(password + passchar))) { passchar = 0; } loopn ++; if(loopn > eight) { if(fwrite(&outBuff, sizeof(outBuff), 1, outFile) != 1) { printf("%s%s", MSG_FWRITE, MSG_DONE); closeAll(); return err_fwrite; } loopn = 0; outBuff = 0; } } } else { if(longrand == true && (randomFile = fopen("/dev/random", "rb"))) { printf(MSG_LONGRAND); } else if((randomFile = fopen("/dev/urandom", "rb"))) { if(verbose == true) printf(MSG_URAND); } else { printf("%s%s", MSG_NORAND, MSG_DONE); return err_norand; } printf("%s%s%s\n", in, MSG_TOE, out); loopn = eight + 1; while(!feof(inFile)) { if(loopn > eight) { if(fread(&inBuff, sizeof(inBuff), 1, inFile) != 1 && !feof(inFile)) { printf("%s%s", MSG_FREAD, MSG_DONE); closeAll(); return err_fwrite; } loopn = 0; } if(randomFile == NULL) outBuff = rand(); else if(fread(&outBuff, sizeof(char), 1, randomFile) != 1) { printf("%s%s", MSG_RANDERR, MSG_DONE); closeAll(); return err_randerr; } place = power2(*(password + passchar) - '0'); if(getBit(inBuff, loopn)) outBuff |= place; else outBuff &= ~place; if(fwrite(&outBuff, sizeof(outBuff), 1, outFile) != 1) { printf("%s%s", MSG_FWRITE, MSG_DONE); closeAll(); return err_fwrite; } loopn ++; passchar ++; if(!(*(password + passchar))) { passchar = 0; } } } closeAll(); printf(MSG_DONE); return none; }
WizWebEngineView::~WizWebEngineView() { closeAll(); }
//----------------------------------------------------------------------------- Bool ClientNetApplyManager::disconnectServers() { closeAll(mNetDriver); return true; }
TabWidget::TabWidget( QWidget* parent ) { qDebug() << "[TABWIDGET] Constructing"; mGrabbedWidget = 0; mTabs = 0; // set the tab position setTabsPosition(); mStatusBar = &mStatusBar->getInstance(); // create the tabbar mBar = new TabBar; setTabBar( mBar ); // connect the mouse clicks connect( mBar, SIGNAL( tabRightClicked( int, QPoint ) ), this, SLOT( tabRightClicked( int, QPoint ) ) ); connect( mBar, SIGNAL( tabMiddleClicked( int, QPoint ) ), this, SLOT( tabMiddleClicked( int, QPoint ) ) ); TabButton* newTabButton = new TabButton( this ); TabButton* mMenuButton = new TabButton( this ); connect( newTabButton, SIGNAL( clicked() ), this, SLOT( addUnityBrowser()) ); connect( newTabButton, SIGNAL( middleClicked() ), this, SLOT( addUnityBrowserWithSR() ) ); connect( mMenuButton, SIGNAL( clicked() ), mMenuButton, SLOT( showMenu()) ); mMenuButton->setMenu( kueueMainMenu() ); newTabButton->setIcon( QIcon( ":icons/menus/newtab.png" ) ); mMenuButton->setIcon( QIcon(":/icons/kueue.png") ); if ( Settings::unityEnabled() ) { setCornerWidget( newTabButton, Qt::TopRightCorner ); } setCornerWidget( mMenuButton, Qt::TopLeftCorner ); // create the main browser tabs... mQueueBrowser = new QueueBrowser( this ); mSubownerBrowser = new SubownerBrowser( this ); mPersonalTab = new BrowserWithSearch( mQueueBrowser, this ); mSubownerTab = new BrowserWithSearch( mSubownerBrowser, this ); connect( mQueueBrowser, SIGNAL( setMenus() ), this, SLOT( setMenus() ) ); connect( mSubownerBrowser, SIGNAL( setMenus() ), this, SLOT( setMenus() ) ); connect( mQueueBrowser, SIGNAL( expandAll() ), this, SLOT( expandAllTables() ) ); connect( mQueueBrowser, SIGNAL( closeAll() ), this, SLOT( closeAllTables() ) ); mQmonBrowser = new QMonBrowser( this ); mMonitorTab = new BrowserWithSearch( mQmonBrowser, this ); mStatsBrowser = new StatsBrowser( this ); mStatsTab = new BrowserWithSearch( mStatsBrowser, this ); if ( Settings::unityEnabled() ) { addUnityBrowser(); rebuildMaps(); } mSubVisible = true; // ...and add them to the tabbar insertTab( 0, mPersonalTab, QIcon( ":icons/conf/targets.png" ), "Personal queue" ); insertTab( 1, mSubownerTab, QIcon( ":icons/conf/targets.png" ), "Subowned SRs" ); insertTab( 2, mMonitorTab, QIcon( ":/icons/conf/monitor.png" ), "Queue monitor" ); insertTab( 3, mStatsTab, QIcon( ":/icons/conf/stats.png" ), "Statistics" ); QShortcut* search = new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_F ), this ); connect( search, SIGNAL( activated() ), this, SLOT( showSearch() ) ); refreshTabs(); }
//------------------------------------------------------------------------------ void TestUI::fini() { closeAll(); destroyActions(); }
XmlOutput& XmlOutput::operator<<(const xml_output& o) { switch(o.xo_type) { case tNothing: break; case tRaw: addRaw(o.xo_text); break; case tDeclaration: addDeclaration(o.xo_text, o.xo_value); break; case tTag: newTagOpen(o.xo_text); break; case tTagValue: addRaw(QString("\n%1<%2>").arg(currentIndent).arg(o.xo_text)); addRaw(doConversion(o.xo_value)); addRaw(QString("</%1>").arg(o.xo_text)); break; case tValueTag: addRaw(doConversion(o.xo_text)); setFormat(NoNewLine); closeTag(); setFormat(NewLine); break; case tImport: addRaw(QString("\n%1<Import %2=\"%3\" />").arg(currentIndent).arg(o.xo_text).arg(o.xo_value)); break; case tCloseTag: if (o.xo_value.count()) closeAll(); else if (o.xo_text.count()) closeTo(o.xo_text); else closeTag(); break; case tAttribute: addAttribute(o.xo_text, o.xo_value); break; case tAttributeTag: addAttributeTag(o.xo_text, o.xo_value); break; case tData: { // Special case to be able to close tag in normal // way ("</tag>", not "/>") without using addRaw().. if (!o.xo_text.count()) { closeOpen(); break; } QString output = doConversion(o.xo_text); output.replace('\n', "\n" + currentIndent); addRaw(QString("\n%1%2").arg(currentIndent).arg(output)); } break; case tComment: { QString output("<!--%1-->"); addRaw(output.arg(o.xo_text)); } break; case tCDATA: { QString output("<![CDATA[\n%1\n]]>"); addRaw(output.arg(o.xo_text)); } break; } return *this; }
void MenuManager::logic() { bool clicking_character = false; bool clicking_inventory = false; bool clicking_powers = false; bool clicking_log = false; ItemStack stack; hudlog->logic(); enemy->logic(); inv->logic(); talker->logic(); if (!inp->pressing[INVENTORY] && !inp->pressing[POWERS] && !inp->pressing[CHARACTER] && !inp->pressing[LOG]) key_lock = false; // check if mouse-clicking a menu button act->checkMenu(inp->mouse, clicking_character, clicking_inventory, clicking_powers, clicking_log); // exit menu toggle if ((inp->pressing[CANCEL] && !inp->lock[CANCEL] && !key_lock && !dragging)) { inp->lock[CANCEL] = true; key_lock = true; if (menus_open) { closeAll(true); } else { exit->visible = !exit->visible; } } // inventory menu toggle if ((inp->pressing[INVENTORY] && !key_lock && !dragging) || clicking_inventory) { key_lock = true; if (inv->visible) { closeRight(true); } else { closeRight(false); inv->visible = true; Mix_PlayChannel(-1, sfx_open, 0); } } // powers menu toggle if ((inp->pressing[POWERS] && !key_lock && !dragging) || clicking_powers) { key_lock = true; if (pow->visible) { closeRight(true); } else { closeRight(false); pow->visible = true; Mix_PlayChannel(-1, sfx_open, 0); } } // character menu toggle if ((inp->pressing[CHARACTER] && !key_lock && !dragging) || clicking_character) { key_lock = true; if (chr->visible) { closeLeft(true); } else { closeLeft(false); chr->visible = true; Mix_PlayChannel(-1, sfx_open, 0); } } // log menu toggle if ((inp->pressing[LOG] && !key_lock && !dragging) || clicking_log) { key_lock = true; if (log->visible) { closeLeft(true); } else { closeLeft(false); log->visible = true; Mix_PlayChannel(-1, sfx_open, 0); } } if (MENUS_PAUSE) { pause = (inv->visible || pow->visible || chr->visible || log->visible || vendor->visible || talker->visible); } menus_open = (inv->visible || pow->visible || chr->visible || log->visible || vendor->visible || talker->visible); if (stats->alive) { int offset_x = (VIEW_W - 320); int offset_y = (VIEW_H - 416)/2; // handle right-click if (!dragging && inp->pressing[MAIN2] && !inp->lock[MAIN2]) { // activate inventory item if (inv->visible && isWithin( inv->carried_area, inp->mouse)) { inv->activate(inp); inp->lock[MAIN2] = true; } } // handle left-click if (!dragging && inp->pressing[MAIN1] && !inp->lock[MAIN1]) { // left side menu if (inp->mouse.x <= 320 && inp->mouse.y >= offset_y && inp->mouse.y <= offset_y+416) { if (chr->visible) { // applied a level-up if (chr->checkUpgrade(inp->mouse)) { inp->lock[MAIN1] = true; // apply equipment and max hp/mp items->applyEquipment(stats, inv->inventory[EQUIPMENT].storage); stats->hp = stats->maxhp; stats->mp = stats->maxmp; } } else if (vendor->visible) { if (inp->pressing[CTRL]) { inp->lock[MAIN1] = true; // buy item from a vendor if (!inv->full()) { stack = vendor->click(inp); if (stack.item > 0) { if( inv->full()) { // Can we say "Not enough place" ? vendor->itemReturn( stack); } else if( ! inv->buy( stack)) { // Can we say "Not enough money" ? (here or in MenuInventory::buy()) vendor->itemReturn( stack); } } } } else { // start dragging a vendor item drag_stack = vendor->click(inp); if (drag_stack.item > 0) { dragging = true; drag_src = DRAG_SRC_VENDOR; inp->lock[MAIN1] = true; } } } else if (log->visible) { // click on a log tab to make it the active display if (isWithin(log->tabs_area, inp->mouse)) { log->clickTab(inp->mouse); inp->lock[MAIN1] = true; } } } // right side menu else if (inp->mouse.x >= offset_x && inp->mouse.y >= offset_y && inp->mouse.y <= offset_y+416) { // pick up an inventory item if (inv->visible) { if (inp->pressing[CTRL]) { inp->lock[MAIN1] = true; stack = inv->click(inp); if( stack.item > 0) { if (vendor->visible) { if( vendor->full()) { // Can we say "Not enough place" ? inv->itemReturn( stack); } else { // The vendor could have a limited amount of money in the future. It will be tested here. if (inv->sell(stack)) { vendor->add(stack); } else { inv->itemReturn(stack); } } } else { if (!inv->sell(stack)) { inv->itemReturn(stack); } } } } else { drag_stack = inv->click(inp); if (drag_stack.item > 0) { dragging = true; drag_src = DRAG_SRC_INVENTORY; inp->lock[MAIN1] = true; } } } // pick up a power else if (pow->visible) { drag_power = pow->click(inp->mouse); if (drag_power > -1) { dragging = true; drag_src = DRAG_SRC_POWERS; inp->lock[MAIN1] = true; } } } // action bar else if (isWithin(act->numberArea,inp->mouse) || isWithin(act->mouseArea,inp->mouse) || isWithin(act->menuArea, inp->mouse)) { // ctrl-click action bar to clear that slot if (inp->pressing[CTRL]) { act->remove(inp->mouse); inp->lock[MAIN1] = true; } // allow drag-to-rearrange action bar else if (!isWithin(act->menuArea, inp->mouse)) { drag_power = act->checkDrag(inp->mouse); if (drag_power > -1) { dragging = true; drag_src = DRAG_SRC_ACTIONBAR; inp->lock[MAIN1] = true; } } // else, clicking action bar to use a power? // this check is done by GameEngine when calling Avatar::logic() } } // handle dropping if (dragging && !inp->pressing[MAIN1]) { // putting a power on the Action Bar if (drag_src == DRAG_SRC_POWERS) { if (isWithin(act->numberArea,inp->mouse) || isWithin(act->mouseArea,inp->mouse)) { act->drop(inp->mouse, drag_power, 0); } } // rearranging the action bar else if (drag_src == DRAG_SRC_ACTIONBAR) { if (isWithin(act->numberArea,inp->mouse) || isWithin(act->mouseArea,inp->mouse)) { act->drop(inp->mouse, drag_power, 1); } } // rearranging inventory or dropping items else if (drag_src == DRAG_SRC_INVENTORY) { if (inv->visible && inp->mouse.x >= offset_x && inp->mouse.y >= offset_y && inp->mouse.y <= offset_y+416) { inv->drop(inp->mouse, drag_stack); drag_stack.item = 0; } else if (isWithin(act->numberArea,inp->mouse) || isWithin(act->mouseArea,inp->mouse)) { // The action bar is not storage! inv->itemReturn(drag_stack); // put an item with a power on the action bar if (items->items[drag_stack.item].power != -1) { act->drop(inp->mouse, items->items[drag_stack.item].power, false); } } else if (vendor->visible && isWithin(vendor->slots_area, inp->mouse)) { // vendor sell item if( vendor->full()) { // Can we say "Not enough place" ? inv->itemReturn( drag_stack); } else { if (inv->sell( drag_stack)) { vendor->add( drag_stack); } else { inv->itemReturn(drag_stack); } } drag_stack.item = 0; } else { // if dragging and the source was inventory, drop item to the floor // quest items cannot be dropped if (items->items[drag_stack.item].type != ITEM_TYPE_QUEST) { drop_stack = drag_stack; drag_stack.item = 0; drag_stack.quantity = 0; } else { inv->itemReturn(drag_stack); } } } else if (drag_src == DRAG_SRC_VENDOR) { // dropping an item from vendor (we only allow to drop into the carried area) if (inv->visible && isWithin( inv->carried_area, inp->mouse)) { if( inv->full()) { // Can we say "Not enough place" ? vendor->itemReturn( drag_stack); } else if( ! inv->buy( drag_stack, inp->mouse)) { // Can we say "Not enough money" ? (here or in MenuInventory::buy()) vendor->itemReturn( drag_stack); } drag_stack.item = 0; } else { vendor->itemReturn(drag_stack); } } dragging = false; } exit->logic(); if (exit->isExitRequested()) { done = true; } } // handle equipment changes affecting hero stats if (inv->changed_equipment || inv->changed_artifact) { items->applyEquipment(stats, inv->inventory[EQUIPMENT].storage); inv->changed_artifact = false; // the equipment flag is reset after the new sprites are loaded } // for action-bar powers that represent items, lookup the current item count for (int i=0; i<12; i++) { act->slot_enabled[i] = true; act->slot_item_count[i] = -1; if (act->hotkeys[i] != -1) { int item_id = powers->powers[act->hotkeys[i]].requires_item; if (item_id != -1 && items->items[item_id].type == ITEM_TYPE_CONSUMABLE) { act->slot_item_count[i] = inv->getItemCountCarried(item_id); if (act->slot_item_count[i] == 0) { act->slot_enabled[i] = false; } } else if (item_id != -1) { // if a non-consumable item power is unequipped, disable that slot if (!inv->isItemEquipped(item_id)) { act->slot_enabled[i] = false; } } } } }
MenuManager::MenuManager(StatBlock *_stats) : stats(_stats) , tip_buf() , keyb_tip_buf_vendor() , keyb_tip_buf_stash() , keyb_tip_buf_pow() , keyb_tip_buf_inv() , keyb_tip_buf_act() , key_lock(false) , mouse_dragging(0) , keyboard_dragging(0) , drag_stack() , drag_power(0) , drag_src(0) , drag_icon(NULL) , done(false) , act_drag_hover(false) , keydrag_pos(Point()) /*std::vector<Menu*> menus;*/ , inv(NULL) , pow(NULL) , chr(NULL) , log(NULL) , hudlog(NULL) , act(NULL) , book(NULL) , hp(NULL) , mp(NULL) , xp(NULL) , tip(NULL) , mini(NULL) , npc(NULL) , enemy(NULL) , vendor(NULL) , talker(NULL) , exit(NULL) , effects(NULL) , stash(NULL) , pause(false) , menus_open(false) { hp = new MenuStatBar("hp"); menus.push_back(hp); // menus[0] mp = new MenuStatBar("mp"); menus.push_back(mp); // menus[1] xp = new MenuStatBar("xp"); menus.push_back(xp); // menus[2] effects = new MenuActiveEffects(stats); menus.push_back(effects); // menus[3] hudlog = new MenuHUDLog(); menus.push_back(hudlog); // menus[4] act = new MenuActionBar(pc); menus.push_back(act); // menus[5] enemy = new MenuEnemy(); menus.push_back(enemy); // menus[6] vendor = new MenuVendor(stats); menus.push_back(vendor); // menus[7] talker = new MenuTalker(this); menus.push_back(talker); // menus[8] exit = new MenuExit(); menus.push_back(exit); // menus[9] mini = new MenuMiniMap(); menus.push_back(mini); // menus[10] chr = new MenuCharacter(stats); menus.push_back(chr); // menus[11] inv = new MenuInventory(stats); menus.push_back(inv); // menus[12] pow = new MenuPowers(stats, act); menus.push_back(pow); // menus[13] log = new MenuLog(); menus.push_back(log); // menus[14] stash = new MenuStash(stats); menus.push_back(stash); // menus[15] npc = new MenuNPCActions(); menus.push_back(npc); // menus[16] book = new MenuBook(); menus.push_back(book); // menus[17] tip = new WidgetTooltip(); pause = false; mouse_dragging = false; keyboard_dragging = false; drag_stack.item = 0; drag_stack.quantity = 0; drag_power = 0; drag_src = 0; done = false; closeAll(); // make sure all togglable menus start closed }
void MidiDriver_CAMD::close() { MidiDriver_MPU401::close(); closeAll(); }
ConnectionManager::~ConnectionManager() { closeAll(); }
MainWindow::MainWindow(const QDir &home) { /*---------------------------------------------------------------------- * Bootstrap *--------------------------------------------------------------------*/ setAttribute(Qt::WA_DeleteOnClose); mainwindows.append(this); // add us to the list of open windows context = new Context(this); context->athlete = new Athlete(context, home); setInstanceName(context->athlete->cyclist); setWindowIcon(QIcon(":images/gc.png")); setWindowTitle(context->athlete->home.dirName()); setContentsMargins(0,0,0,0); setAcceptDrops(true); GCColor *GCColorSet = new GCColor(context); // get/keep colorset GCColorSet->colorSet(); // shut up the compiler #ifdef Q_OS_MAC // get an autorelease pool setup static CocoaInitializer cocoaInitializer; #endif #ifdef GC_HAVE_WFAPI WFApi *w = WFApi::getInstance(); // ensure created on main thread w->apiVersion();//shutup compiler #endif Library::initialise(context->athlete->home); QNetworkProxyQuery npq(QUrl("http://www.google.com")); QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq); if (listOfProxies.count() > 0) { QNetworkProxy::setApplicationProxy(listOfProxies.first()); } if (desktop == NULL) desktop = QApplication::desktop(); static const QIcon hideIcon(":images/toolbar/main/hideside.png"); static const QIcon rhideIcon(":images/toolbar/main/hiderside.png"); static const QIcon showIcon(":images/toolbar/main/showside.png"); static const QIcon rshowIcon(":images/toolbar/main/showrside.png"); static const QIcon tabIcon(":images/toolbar/main/tab.png"); static const QIcon tileIcon(":images/toolbar/main/tile.png"); static const QIcon fullIcon(":images/toolbar/main/togglefull.png"); #if (defined Q_OS_MAC) && (defined GC_HAVE_LION) fullScreen = new LionFullScreen(context); #endif #ifndef Q_OS_MAC fullScreen = new QTFullScreen(context); #endif // if no workout directory is configured, default to the // top level GoldenCheetah directory if (appsettings->value(NULL, GC_WORKOUTDIR).toString() == "") appsettings->setValue(GC_WORKOUTDIR, QFileInfo(context->athlete->home.absolutePath() + "/../").absolutePath()); /*---------------------------------------------------------------------- * GUI setup *--------------------------------------------------------------------*/ // need to restore geometry before setUnifiedToolBar.. on Mac appsettings->setValue(GC_SETTINGS_LAST, context->athlete->home.dirName()); QVariant geom = appsettings->value(this, GC_SETTINGS_MAIN_GEOM); if (geom == QVariant()) { // first run -- lets set some sensible defaults... // lets put it in the middle of screen 1 QRect size = desktop->availableGeometry(); struct SizeSettings app = GCColor::defaultSizes(size.height(), size.width()); // center on the available screen (minus toolbar/sidebar) move((size.width()-size.x())/2 - app.width/2, (size.height()-size.y())/2 - app.height/2); // set to the right default resize(app.width, app.height); // set all the default font sizes appsettings->setValue(GC_FONT_DEFAULT_SIZE, app.defaultFont); appsettings->setValue(GC_FONT_TITLES_SIZE, app.titleFont); appsettings->setValue(GC_FONT_CHARTMARKERS_SIZE, app.markerFont); appsettings->setValue(GC_FONT_CHARTLABELS_SIZE, app.labelFont); appsettings->setValue(GC_FONT_CALENDAR_SIZE, app.calendarFont); appsettings->setValue(GC_FONT_POPUP_SIZE, app.popupFont); // set the default fontsize QFont font; font.setPointSize(app.defaultFont); QApplication::setFont(font); } else { QRect size = desktop->availableGeometry(); // ensure saved geometry isn't greater than current screen size if ((geom.toRect().height() >= size.height()) || (geom.toRect().width() >= size.width())) setGeometry(size.x()+30,size.y()+30,size.width()-60,size.height()-60); else setGeometry(geom.toRect()); } /*---------------------------------------------------------------------- * Mac Toolbar *--------------------------------------------------------------------*/ #ifdef Q_OS_MAC setUnifiedTitleAndToolBarOnMac(true); head = addToolBar(context->athlete->cyclist); head->setContentsMargins(0,0,0,0); // widgets QWidget *macAnalButtons = new QWidget(this); macAnalButtons->setContentsMargins(0,0,20,0); // lhs buttons QHBoxLayout *lb = new QHBoxLayout(macAnalButtons); lb->setContentsMargins(0,0,0,0); lb->setSpacing(0); import = new QtMacButton(this, QtMacButton::TexturedRounded); QPixmap *importImg = new QPixmap(":images/mac/download.png"); import->setImage(importImg); import->setToolTip("Download"); lb->addWidget(import); lb->addWidget(new Spacer(this)); compose = new QtMacButton(this, QtMacButton::TexturedRounded); QPixmap *composeImg = new QPixmap(":images/mac/compose.png"); compose->setImage(composeImg); compose->setToolTip("Create"); lb->addWidget(compose); // connect to actions connect(import, SIGNAL(clicked(bool)), this, SLOT(downloadRide())); connect(compose, SIGNAL(clicked(bool)), this, SLOT(manualRide())); lb->addWidget(new Spacer(this)); // activity actions .. peaks, split, delete QWidget *acts = new QWidget(this); acts->setContentsMargins(0,0,0,0); QHBoxLayout *pp = new QHBoxLayout(acts); pp->setContentsMargins(0,0,0,0); pp->setContentsMargins(0,0,0,0); pp->setSpacing(5); sidebar = new QtMacButton(this, QtMacButton::TexturedRounded); QPixmap *sidebarImg = new QPixmap(":images/mac/sidebar.png"); sidebar->setImage(sidebarImg); sidebar->setMinimumSize(25, 25); sidebar->setMaximumSize(25, 25); sidebar->setToolTip("Sidebar"); sidebar->setSelected(true); // assume always start up with sidebar selected actbuttons = new QtMacSegmentedButton(3, acts); actbuttons->setWidth(115); actbuttons->setNoSelect(); actbuttons->setImage(0, new QPixmap(":images/mac/stop.png")); actbuttons->setImage(1, new QPixmap(":images/mac/split.png")); actbuttons->setImage(2, new QPixmap(":images/mac/trash.png")); pp->addWidget(actbuttons); lb->addWidget(acts); lb->addStretch(); connect(actbuttons, SIGNAL(clicked(int,bool)), this, SLOT(actionClicked(int))); lb->addWidget(new Spacer(this)); QWidget *viewsel = new QWidget(this); viewsel->setContentsMargins(0,0,0,0); QHBoxLayout *pq = new QHBoxLayout(viewsel); pq->setContentsMargins(0,0,0,0); pq->setSpacing(5); pq->addWidget(sidebar); styleSelector = new QtMacSegmentedButton(2, viewsel); styleSelector->setWidth(80); // actually its 80 but we want a 30px space between is and the searchbox styleSelector->setImage(0, new QPixmap(":images/mac/tabbed.png"), 24); styleSelector->setImage(1, new QPixmap(":images/mac/tiled.png"), 24); pq->addWidget(styleSelector); connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar())); connect(styleSelector, SIGNAL(clicked(int,bool)), this, SLOT(toggleStyle())); // setup Mac thetoolbar head->addWidget(macAnalButtons); head->addWidget(new Spacer(this)); head->addWidget(new Spacer(this)); head->addWidget(viewsel); #ifdef GC_HAVE_LUCENE SearchFilterBox *searchBox = new SearchFilterBox(this,context,false); QCleanlooksStyle *toolStyle = new QCleanlooksStyle(); searchBox->setStyle(toolStyle); searchBox->setFixedWidth(200); head->addWidget(searchBox); connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList))); connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter())); #endif #endif /*---------------------------------------------------------------------- * Windows and Linux Toolbar *--------------------------------------------------------------------*/ #ifndef Q_OS_MAC head = new GcToolBar(this); QCleanlooksStyle *toolStyle = new QCleanlooksStyle(); QPalette metal; metal.setColor(QPalette::Button, QColor(215,215,215)); // get those icons importIcon = iconFromPNG(":images/mac/download.png"); composeIcon = iconFromPNG(":images/mac/compose.png"); intervalIcon = iconFromPNG(":images/mac/stop.png"); splitIcon = iconFromPNG(":images/mac/split.png"); deleteIcon = iconFromPNG(":images/mac/trash.png"); sidebarIcon = iconFromPNG(":images/mac/sidebar.png"); tabbedIcon = iconFromPNG(":images/mac/tabbed.png"); tiledIcon = iconFromPNG(":images/mac/tiled.png"); QSize isize(19,19); Spacer *spacerl = new Spacer(this); spacerl->setFixedWidth(5); import = new QPushButton(this); import->setIcon(importIcon); import->setIconSize(isize); import->setFixedHeight(25); import->setStyle(toolStyle); import->setToolTip(tr("Download from Device")); import->setPalette(metal); connect(import, SIGNAL(clicked(bool)), this, SLOT(downloadRide())); compose = new QPushButton(this); compose->setIcon(composeIcon); compose->setIconSize(isize); compose->setFixedHeight(25); compose->setStyle(toolStyle); compose->setToolTip(tr("Create Manual Activity")); compose->setPalette(metal); connect(compose, SIGNAL(clicked(bool)), this, SLOT(manualRide())); sidebar = new QPushButton(this); sidebar->setIcon(sidebarIcon); sidebar->setIconSize(isize); sidebar->setFixedHeight(25); sidebar->setStyle(toolStyle); sidebar->setToolTip(tr("Toggle Sidebar")); sidebar->setPalette(metal); connect(sidebar, SIGNAL(clicked(bool)), this, SLOT(toggleSidebar())); actbuttons = new QtSegmentControl(this); actbuttons->setStyle(toolStyle); actbuttons->setIconSize(isize); actbuttons->setCount(3); actbuttons->setSegmentIcon(0, intervalIcon); actbuttons->setSegmentIcon(1, splitIcon); actbuttons->setSegmentIcon(2, deleteIcon); actbuttons->setSelectionBehavior(QtSegmentControl::SelectNone); //wince. spelling. ugh actbuttons->setFixedHeight(25); actbuttons->setSegmentToolTip(0, tr("Find Intervals...")); actbuttons->setSegmentToolTip(1, tr("Split Activity...")); actbuttons->setSegmentToolTip(2, tr("Delete Activity")); actbuttons->setPalette(metal); connect(actbuttons, SIGNAL(segmentSelected(int)), this, SLOT(actionClicked(int))); styleSelector = new QtSegmentControl(this); styleSelector->setStyle(toolStyle); styleSelector->setIconSize(isize); styleSelector->setCount(2); styleSelector->setSegmentIcon(0, tabbedIcon); styleSelector->setSegmentIcon(1, tiledIcon); styleSelector->setSegmentToolTip(0, tr("Tabbed View")); styleSelector->setSegmentToolTip(1, tr("Tiled View")); styleSelector->setSelectionBehavior(QtSegmentControl::SelectOne); //wince. spelling. ugh styleSelector->setFixedHeight(25); styleSelector->setPalette(metal); connect(styleSelector, SIGNAL(segmentSelected(int)), this, SLOT(setStyleFromSegment(int))); //avoid toggle infinitely head->addWidget(spacerl); head->addWidget(import); head->addWidget(compose); head->addWidget(actbuttons); head->addStretch(); head->addWidget(sidebar); head->addWidget(styleSelector); #ifdef GC_HAVE_LUCENE // add a search box on far right, but with a little space too SearchFilterBox *searchBox = new SearchFilterBox(this,context,false); searchBox->setStyle(toolStyle); searchBox->setFixedWidth(200); head->addWidget(searchBox); connect(searchBox, SIGNAL(searchResults(QStringList)), this, SLOT(setFilter(QStringList))); connect(searchBox, SIGNAL(searchClear()), this, SLOT(clearFilter())); #endif Spacer *spacer = new Spacer(this); spacer->setFixedWidth(5); head->addWidget(spacer); #endif /*---------------------------------------------------------------------- * ScopeBar *--------------------------------------------------------------------*/ scopebar = new GcScopeBar(context); connect(scopebar, SIGNAL(selectDiary()), this, SLOT(selectDiary())); connect(scopebar, SIGNAL(selectHome()), this, SLOT(selectHome())); connect(scopebar, SIGNAL(selectAnal()), this, SLOT(selectAnalysis())); connect(scopebar, SIGNAL(selectTrain()), this, SLOT(selectTrain())); // Add chart is on the scope bar chartMenu = new QMenu(this); QCleanlooksStyle *styler = new QCleanlooksStyle(); QPushButton *newchart = new QPushButton("+", this); scopebar->addWidget(newchart); newchart->setStyle(styler); newchart->setFixedHeight(20); newchart->setFixedWidth(24); newchart->setFlat(true); newchart->setFocusPolicy(Qt::NoFocus); newchart->setToolTip(tr("Add Chart")); newchart->setAutoFillBackground(false); newchart->setAutoDefault(false); newchart->setMenu(chartMenu); connect(chartMenu, SIGNAL(aboutToShow()), this, SLOT(setChartMenu())); connect(chartMenu, SIGNAL(triggered(QAction*)), this, SLOT(addChart(QAction*))); /*---------------------------------------------------------------------- * Central Widget *--------------------------------------------------------------------*/ tab = new Tab(context); /*---------------------------------------------------------------------- * Central Widget *--------------------------------------------------------------------*/ QWidget *central = new QWidget(this); setContentsMargins(0,0,0,0); central->setContentsMargins(0,0,0,0); QVBoxLayout *mainLayout = new QVBoxLayout(central); mainLayout->setSpacing(0); mainLayout->setContentsMargins(0,0,0,0); #ifndef Q_OS_MAC // nonmac toolbar on main view -- its not // unified with the title bar. mainLayout->addWidget(head); #endif mainLayout->addWidget(scopebar); mainLayout->addWidget(tab); setCentralWidget(central); /*---------------------------------------------------------------------- * Application Menus *--------------------------------------------------------------------*/ #ifdef WIN32 menuBar()->setStyleSheet("QMenuBar { background: rgba(225,225,225); }" "QMenuBar::item { background: rgba(225,225,225); }"); menuBar()->setContentsMargins(0,0,0,0); #endif QMenu *fileMenu = menuBar()->addMenu(tr("&Athlete")); fileMenu->addAction(tr("&New..."), this, SLOT(newCyclist()), tr("Ctrl+N")); fileMenu->addAction(tr("&Open..."), this, SLOT(openCyclist()), tr("Ctrl+O")); fileMenu->addAction(tr("&Close Window"), this, SLOT(close()), tr ("Ctrl+W")); fileMenu->addAction(tr("&Quit All Windows"), this, SLOT(closeAll()), tr("Ctrl+Q")); QMenu *rideMenu = menuBar()->addMenu(tr("A&ctivity")); rideMenu->addAction(tr("&Download from device..."), this, SLOT(downloadRide()), tr("Ctrl+D")); rideMenu->addAction(tr("&Import from file..."), this, SLOT (importFile()), tr ("Ctrl+I")); rideMenu->addAction(tr("&Manual activity entry..."), this, SLOT(manualRide()), tr("Ctrl+M")); rideMenu->addSeparator (); rideMenu->addAction(tr("&Export..."), this, SLOT(exportRide()), tr("Ctrl+E")); rideMenu->addAction(tr("&Batch export..."), this, SLOT(exportBatch()), tr("Ctrl+B")); rideMenu->addAction(tr("Export Metrics as CSV..."), this, SLOT(exportMetrics()), tr("")); #ifdef GC_HAVE_SOAP rideMenu->addSeparator (); rideMenu->addAction(tr("&Upload to TrainingPeaks"), this, SLOT(uploadTP()), tr("Ctrl+U")); rideMenu->addAction(tr("Down&load from TrainingPeaks..."), this, SLOT(downloadTP()), tr("Ctrl+L")); #endif #ifdef GC_HAVE_LIBOAUTH tweetAction = new QAction(tr("Tweet Activity"), this); connect(tweetAction, SIGNAL(triggered(bool)), this, SLOT(tweetRide())); rideMenu->addAction(tweetAction); shareAction = new QAction(tr("Share (Strava, RideWithGPS, CyclingAnalytics)..."), this); connect(shareAction, SIGNAL(triggered(bool)), this, SLOT(share())); rideMenu->addAction(shareAction); #endif ttbAction = new QAction(tr("Upload to Trainingstagebuch..."), this); connect(ttbAction, SIGNAL(triggered(bool)), this, SLOT(uploadTtb())); rideMenu->addAction(ttbAction); rideMenu->addSeparator (); rideMenu->addAction(tr("&Save activity"), this, SLOT(saveRide()), tr("Ctrl+S")); rideMenu->addAction(tr("D&elete activity..."), this, SLOT(deleteRide())); rideMenu->addAction(tr("Split &activity..."), this, SLOT(splitRide())); rideMenu->addAction(tr("Merge activities..."), this, SLOT(mergeRide())); rideMenu->addSeparator (); QMenu *optionsMenu = menuBar()->addMenu(tr("&Tools")); optionsMenu->addAction(tr("&Options..."), this, SLOT(showOptions())); optionsMenu->addAction(tr("Critical Power Estimator..."), this, SLOT(showTools())); optionsMenu->addAction(tr("Air Density (Rho) Estimator..."), this, SLOT(showRhoEstimator())); optionsMenu->addSeparator(); optionsMenu->addAction(tr("Get &Withings Data..."), this, SLOT (downloadMeasures())); optionsMenu->addAction(tr("Get &Zeo Data..."), this, SLOT (downloadMeasuresFromZeo())); optionsMenu->addSeparator(); optionsMenu->addAction(tr("Create a new workout..."), this, SLOT(showWorkoutWizard())); optionsMenu->addAction(tr("Download workouts from ErgDB..."), this, SLOT(downloadErgDB())); optionsMenu->addAction(tr("Import workouts or videos..."), this, SLOT(importWorkout())); optionsMenu->addAction(tr("Scan disk for videos and workouts..."), this, SLOT(manageLibrary())); #ifdef GC_HAVE_ICAL optionsMenu->addSeparator(); optionsMenu->addAction(tr("Upload Activity to Calendar"), this, SLOT(uploadCalendar()), tr ("")); //optionsMenu->addAction(tr("Import Calendar..."), this, SLOT(importCalendar()), tr ("")); // planned for v3.1 //optionsMenu->addAction(tr("Export Calendar..."), this, SLOT(exportCalendar()), tr ("")); // planned for v3.1 optionsMenu->addAction(tr("Refresh Calendar"), this, SLOT(refreshCalendar()), tr ("")); #endif optionsMenu->addSeparator(); optionsMenu->addAction(tr("Find intervals..."), this, SLOT(addIntervals()), tr ("")); // Add all the data processors to the tools menu const DataProcessorFactory &factory = DataProcessorFactory::instance(); QMap<QString, DataProcessor*> processors = factory.getProcessors(); if (processors.count()) { optionsMenu->addSeparator(); toolMapper = new QSignalMapper(this); // maps each option QMapIterator<QString, DataProcessor*> i(processors); connect(toolMapper, SIGNAL(mapped(const QString &)), this, SLOT(manualProcess(const QString &))); i.toFront(); while (i.hasNext()) { i.next(); // The localized processor name is shown in menu QAction *action = new QAction(QString("%1...").arg(i.value()->name()), this); optionsMenu->addAction(action); connect(action, SIGNAL(triggered()), toolMapper, SLOT(map())); toolMapper->setMapping(action, i.key()); } }
void MenuManager::logic() { bool clicking_character = false; bool clicking_inventory = false; bool clicking_powers = false; bool clicking_log = false; ItemStack stack; hp->update(stats->hp,stats->maxhp,inpt->mouse,""); mp->update(stats->mp,stats->maxmp,inpt->mouse,""); xp->update((stats->xp - stats->xp_table[stats->level-1]),(stats->xp_table[stats->level] - stats->xp_table[stats->level-1]),inpt->mouse,msg->get("XP: %d/%d", stats->xp, stats->xp_table[stats->level])); effects->update(stats); hudlog->logic(); enemy->logic(); chr->logic(); inv->logic(); vendor->logic(); pow->logic(); log->logic(); talker->logic(); stash->logic(); if (chr->checkUpgrade() || stats->level_up) { // apply equipment and max hp/mp inv->applyEquipment(inv->inventory[EQUIPMENT].storage); stats->hp = stats->maxhp; stats->mp = stats->maxmp; stats->level_up = false; } // only allow the vendor window to be open if the inventory is open if (vendor->visible && !(inv->visible)) { closeLeft(false); if (vendor->talker_visible && !(inv->visible)) closeRight(true); } if (!inpt->pressing[INVENTORY] && !inpt->pressing[POWERS] && !inpt->pressing[CHARACTER] && !inpt->pressing[LOG]) key_lock = false; // check if mouse-clicking a menu button act->checkMenu(inpt->mouse, clicking_character, clicking_inventory, clicking_powers, clicking_log); if (exit->visible) { exit->logic(); if (exit->isExitRequested()) { done = true; } } // exit menu toggle if ((inpt->pressing[CANCEL] && !inpt->lock[CANCEL] && !key_lock && !dragging) && !(stats->corpse && stats->permadeath) && stats->transform_duration < 1) { inpt->lock[CANCEL] = true; key_lock = true; if (menus_open) { closeAll(true); } else { exit->visible = !exit->visible; } } // inventory menu toggle if ((inpt->pressing[INVENTORY] && !key_lock && !dragging) || clicking_inventory) { key_lock = true; if (inv->visible) { closeRight(true); } else { closeRight(false); act->requires_attention[MENU_INVENTORY] = false; inv->visible = true; if (sfx_open) Mix_PlayChannel(-1, sfx_open, 0); } } // powers menu toggle if (((inpt->pressing[POWERS] && !key_lock && !dragging) || clicking_powers) && stats->humanoid) { key_lock = true; if (pow->visible) { closeRight(true); } else { closeRight(false); act->requires_attention[MENU_POWERS] = false; pow->visible = true; if (sfx_open) Mix_PlayChannel(-1, sfx_open, 0); } } act->requires_attention[MENU_POWERS] = pow->getUnspent() > 0; // character menu toggleggle if (((inpt->pressing[CHARACTER] && !key_lock && !dragging) || clicking_character) && stats->humanoid) { key_lock = true; if (chr->visible) { closeLeft(true); } else { closeLeft(false); act->requires_attention[MENU_CHARACTER] = false; chr->visible = true; if (sfx_open) Mix_PlayChannel(-1, sfx_open, 0); // Make sure the stat list isn't scrolled when we open the character menu inpt->resetScroll(); } } act->requires_attention[MENU_CHARACTER] = chr->getUnspent() > 0; // log menu toggle if ((inpt->pressing[LOG] && !key_lock && !dragging) || clicking_log) { key_lock = true; if (log->visible) { closeLeft(true); } else { closeLeft(false); act->requires_attention[MENU_LOG] = false; log->visible = true; if (sfx_open) Mix_PlayChannel(-1, sfx_open, 0); // Make sure the log isn't scrolled when we open the log menu inpt->resetScroll(); } } if (MENUS_PAUSE) { pause = (inv->visible || pow->visible || chr->visible || log->visible || vendor->visible || talker->visible); } menus_open = (inv->visible || pow->visible || chr->visible || log->visible || vendor->visible || talker->visible); if (stats->alive) { // handle right-click if (!dragging && inpt->pressing[MAIN2] && !inpt->lock[MAIN2]) { // exit menu if (exit->visible && isWithin(exit->window_area, inpt->mouse)) { inpt->lock[MAIN2] = true; } // activate inventory item else if (inv->visible && isWithin(inv->window_area, inpt->mouse)) { inpt->lock[MAIN2] = true; if (isWithin(inv->carried_area, inpt->mouse)) { inv->activate(inpt); } } } // handle left-click if (!dragging && inpt->pressing[MAIN1] && !inpt->lock[MAIN1]) { // exit menu if (exit->visible && isWithin(exit->window_area, inpt->mouse)) { inpt->lock[MAIN1] = true; } if (chr->visible && isWithin(chr->window_area, inpt->mouse)) { inpt->lock[MAIN1] = true; } if (vendor->visible && isWithin(vendor->window_area,inpt->mouse)) { inpt->lock[MAIN1] = true; vendor->tabsLogic(); if (inpt->pressing[CTRL]) { // buy item from a vendor stack = vendor->click(inpt); if (stack.item > 0) { if( ! inv->buy( stack)) { log->add(msg->get("Not enough money."), LOG_TYPE_MESSAGES); hudlog->add(msg->get("Not enough money.")); vendor->itemReturn( stack); } else { if( inv->full(stack.item)) { log->add(msg->get("Inventory is full."), LOG_TYPE_MESSAGES); hudlog->add(msg->get("Inventory is full.")); drop_stack = stack; } else { inv->add(stack); } } } } else { // start dragging a vendor item drag_stack = vendor->click(inpt); if (drag_stack.item > 0) { dragging = true; drag_src = DRAG_SRC_VENDOR; } } } if (stash->visible && isWithin(stash->window_area,inpt->mouse)) { inpt->lock[MAIN1] = true; if (inpt->pressing[CTRL]) { // take an item from the stash stack = stash->click(inpt); if (stack.item > 0) { if( inv->full(stack.item)) { log->add(msg->get("Inventory is full."), LOG_TYPE_MESSAGES); hudlog->add(msg->get("Inventory is full.")); drop_stack = stack; } else { inv->add(stack); } stash->updated = true; } } else { // start dragging a stash item drag_stack = stash->click(inpt); if (drag_stack.item > 0) { dragging = true; drag_src = DRAG_SRC_STASH; } } } if(log->visible && isWithin(log->window_area,inpt->mouse)) { inpt->lock[MAIN1] = true; log->tabsLogic(); } // pick up an inventory item if (inv->visible && isWithin(inv->window_area,inpt->mouse)) { if (inpt->pressing[CTRL]) { inpt->lock[MAIN1] = true; stack = inv->click(inpt); if( stack.item > 0) { if (stash->visible) { if (inv->stashAdd(stack) && !stash->full(stack.item)) { stash->add(stack); stash->updated = true; } else { inv->itemReturn(stack); } } else { // The vendor could have a limited amount of money in the future. It will be tested here. if ((SELL_WITHOUT_VENDOR || vendor->visible) && inv->sell(stack)) { vendor->setTab(VENDOR_SELL); vendor->add(stack); } else { inv->itemReturn(stack); } } } } else { inpt->lock[MAIN1] = true; drag_stack = inv->click(inpt); if (drag_stack.item > 0) { dragging = true; drag_src = DRAG_SRC_INVENTORY; } } } // pick up a power if (pow->visible && isWithin(pow->window_area,inpt->mouse)) { inpt->lock[MAIN1] = true; // check for unlock first if (!pow->unlockClick(inpt->mouse)) { // otherwise, check for dragging drag_power = pow->click(inpt->mouse); if (drag_power > 0) { dragging = true; drag_src = DRAG_SRC_POWERS; } } } // action bar if (isWithin(act->numberArea,inpt->mouse) || isWithin(act->mouseArea,inpt->mouse) || isWithin(act->menuArea, inpt->mouse)) { inpt->lock[MAIN1] = true; // ctrl-click action bar to clear that slot if (inpt->pressing[CTRL]) { act->remove(inpt->mouse); } // allow drag-to-rearrange action bar else if (!isWithin(act->menuArea, inpt->mouse)) { drag_power = act->checkDrag(inpt->mouse); if (drag_power > 0) { dragging = true; drag_src = DRAG_SRC_ACTIONBAR; } } // else, clicking action bar to use a power? // this check is done by GameEngine when calling Avatar::logic() } } // handle dropping if (dragging && !inpt->pressing[MAIN1]) { // putting a power on the Action Bar if (drag_src == DRAG_SRC_POWERS) { if (isWithin(act->numberArea,inpt->mouse) || isWithin(act->mouseArea,inpt->mouse)) { act->drop(inpt->mouse, drag_power, 0); } } // rearranging the action bar else if (drag_src == DRAG_SRC_ACTIONBAR) { if (isWithin(act->numberArea,inpt->mouse) || isWithin(act->mouseArea,inpt->mouse)) { act->drop(inpt->mouse, drag_power, 1); // for locked slots forbid power dropping } else if (act->locked[act->drag_prev_slot]) { act->hotkeys[act->drag_prev_slot] = drag_power; } } // rearranging inventory or dropping items else if (drag_src == DRAG_SRC_INVENTORY) { if (inv->visible && isWithin(inv->window_area, inpt->mouse)) { inv->drop(inpt->mouse, drag_stack); drag_stack.item = 0; } else if (isWithin(act->numberArea,inpt->mouse) || isWithin(act->mouseArea,inpt->mouse)) { // The action bar is not storage! inv->itemReturn(drag_stack); // put an item with a power on the action bar if (items->items[drag_stack.item].power != 0) { act->drop(inpt->mouse, items->items[drag_stack.item].power, false); } } else if (vendor->visible && isWithin(vendor->slots_area, inpt->mouse)) { if (inv->sell( drag_stack)) { vendor->setTab(VENDOR_SELL); vendor->add( drag_stack); } else { inv->itemReturn(drag_stack); } drag_stack.item = 0; } else if (stash->visible && isWithin(stash->slots_area, inpt->mouse)) { if (inv->stashAdd( drag_stack) && !stash->full(drag_stack.item)) { stash->drop(inpt->mouse, drag_stack); stash->updated = true; } else { inv->itemReturn(drag_stack); } drag_stack.item = 0; } else { // if dragging and the source was inventory, drop item to the floor // quest items cannot be dropped if (items->items[drag_stack.item].type != "quest") { drop_stack = drag_stack; drag_stack.item = 0; drag_stack.quantity = 0; } else { inv->itemReturn(drag_stack); } } } else if (drag_src == DRAG_SRC_VENDOR) { // dropping an item from vendor (we only allow to drop into the carried area) if (inv->visible && isWithin( inv->carried_area, inpt->mouse)) { if( ! inv->buy( drag_stack)) { log->add(msg->get("Not enough money."), LOG_TYPE_MESSAGES); hudlog->add(msg->get("Not enough money.")); vendor->itemReturn( drag_stack); } else { if( inv->full(drag_stack.item)) { log->add(msg->get("Inventory is full."), LOG_TYPE_MESSAGES); hudlog->add(msg->get("Inventory is full.")); drop_stack = drag_stack; } else { inv->drop(inpt->mouse,drag_stack); } } drag_stack.item = 0; drag_stack.quantity = 0; } else { vendor->itemReturn(drag_stack); } } else if (drag_src == DRAG_SRC_STASH) { // dropping an item from stash (we only allow to drop into the carried area) if (inv->visible && isWithin( inv->carried_area, inpt->mouse)) { if( inv->full(drag_stack.item)) { log->add(msg->get("Inventory is full."), LOG_TYPE_MESSAGES); hudlog->add(msg->get("Inventory is full.")); // quest items cannot be dropped if (items->items[drag_stack.item].type != "quest") { drop_stack = drag_stack; } else { stash->itemReturn(drag_stack); } } else { inv->drop(inpt->mouse,drag_stack); } stash->updated = true; drag_stack.item = 0; drag_stack.quantity = 0; } else if (stash->visible && isWithin(stash->slots_area, inpt->mouse)) { stash->drop(inpt->mouse,drag_stack); } else { stash->itemReturn( drag_stack); } } dragging = false; } } // handle equipment changes affecting hero stats if (inv->changed_equipment || inv->changed_artifact) { inv->applyEquipment(inv->inventory[EQUIPMENT].storage); inv->changed_artifact = false; // the equipment flag is reset after the new sprites are loaded } // for action-bar powers that represent items, lookup the current item count for (int i=0; i<12; i++) { act->slot_enabled[i] = true; act->slot_item_count[i] = -1; if (act->hotkeys[i] != -1) { int item_id = powers->powers[act->hotkeys[i]].requires_item; if (item_id != -1 && items->items[item_id].type == "consumable") { act->slot_item_count[i] = inv->getItemCountCarried(item_id); if (act->slot_item_count[i] == 0) { act->slot_enabled[i] = false; } } else if (item_id != -1) { // if a non-consumable item power is unequipped, disable that slot if (!inv->isItemEquipped(item_id)) { act->slot_enabled[i] = false; } } } } }
void OneToManyProcessor::close() { closeAll(); }