Scene1105::Scene1105(NeverhoodEngine *vm, Module *parentModule) : Scene(vm, parentModule), _countdown(0), _isPanelOpen(false), _isActionButtonClicked(false), _doMoveTeddy(false), _isClosePanelDone(false), _leaveResult(0), _backgroundIndex(0) { Sprite *ssOpenButton; _vm->gameModule()->initMemoryPuzzle(); SetUpdateHandler(&Scene1105::update); SetMessageHandler(&Scene1105::handleMessage); setBackground(0x20010002); setPalette(0x20010002); _asTeddyBear = insertSprite<AsScene1105TeddyBear>(this); ssOpenButton = insertSprite<SsScene1105OpenButton>(this); addCollisionSprite(ssOpenButton); insertPuzzleMouse(0x10006208, 20, 620); loadSound(0, 0x48442057); loadSound(1, 0xC025014F); loadSound(2, 0x68E25540); }
void LogicAnalyzerDisplay::populateChannel(const int channel, const Pothos::Packet &packet) { //convert buffer (does not convert when type matches) const auto numericBuff = packet.payload.convert(typeid(T)); assert(_chData.size() > channel); _chData[channel] = packet; _chData[channel].payload = numericBuff; //load element data into table for (size_t i = 0; i < numericBuff.elements(); i++) { const auto num = numericBuff.as<const T *>()[i]; const auto s = toStr(num, _chBase.at(channel)); auto item = new QTableWidgetItem(s); auto flags = item->flags(); flags &= ~Qt::ItemIsEditable; item->setFlags(flags); item->setTextAlignment(Qt::AlignRight); _tableView->setItem(channel, i, item); } //inspect labels to decorate table for (const auto &label : packet.labels) { const int column = label.index; assert(column < _tableView->columnCount()); auto item = _tableView->item(channel, column); //highlight and display label id item->setBackground(Qt::yellow); item->setText(QString("%1\n%2") .arg(item->text()) .arg(QString::fromStdString(label.id))); _tableView->resizeColumnToContents(column); } }
Scene2901::Scene2901(NeverhoodEngine *vm, Module *parentModule, int which) : Scene(vm, parentModule), _currLocationButtonNum(which), _selectedButtonNum(which), _currWhirlButtonNum(0), _prevWhirlButtonNum(0), _countdown1(1), _skipCountdown(0), _blinkOn(0) { _isButton2Broken = getGlobalVar(V_ENTRANCE_OPEN) != 0; setSubVar(V_TELEPORTER_DEST_AVAILABLE, which, 1); setSubVar(V_TELEPORTER_DEST_AVAILABLE, 5, 1); setSubVar(V_TELEPORTER_DEST_AVAILABLE, 4, 1); if (_currLocationButtonNum == 3) setSubVar(V_TELEPORTER_DEST_AVAILABLE, 2, 1); setBackground(kScene2901FileHashes1[_currLocationButtonNum]); setPalette(kScene2901FileHashes1[_currLocationButtonNum]); for (uint i = 0; i < 6; ++i) { if (i != 2 || !_isButton2Broken) { _ssLocationButtons[i] = insertSprite<SsScene2901LocationButton>(this, _currLocationButtonNum, i); addCollisionSprite(_ssLocationButtons[i]); _ssLocationButtonLights[i] = insertSprite<SsScene2901LocationButtonLight>(_currLocationButtonNum, i); } } if (_isButton2Broken) insertSprite<SsScene2901BrokenButton>(_currLocationButtonNum); _ssBigButton = insertSprite<SsScene2901BigButton>(this, _currLocationButtonNum); addCollisionSprite(_ssBigButton); insertPuzzleMouse(kScene2901FileHashes2[_currLocationButtonNum], 20, 620); SetUpdateHandler(&Scene2901::update); SetMessageHandler(&Scene2901::handleMessage); }
void SettingsDlg::updateStyleSample() { QColor txtColor = getColor( PROP_FONT_COLOR, 0x000000 ); QColor bgColor = getColor( PROP_BACKGROUND_COLOR, 0xFFFFFF ); QColor headerColor = getColor( PROP_STATUS_FONT_COLOR, 0xFFFFFF ); QColor selectionColor = getColor( PROP_HIGHLIGHT_SELECTION_COLOR, 0xC0C0C0 ); QColor commentColor = getColor( PROP_HIGHLIGHT_BOOKMARK_COLOR_COMMENT, 0xC0C000 ); QColor correctionColor = getColor( PROP_HIGHLIGHT_BOOKMARK_COLOR_CORRECTION, 0xC00000 ); setBackground( m_ui->frmTextColor, txtColor ); setBackground( m_ui->frmBgColor, bgColor ); setBackground( m_ui->frmHeaderTextColor, headerColor ); setBackground( m_ui->frmSelectionColor, selectionColor ); setBackground( m_ui->frmCommentColor, commentColor ); setBackground( m_ui->frmCorrectionColor, correctionColor ); m_ui->crSample->setOptions( m_props ); m_ui->crSample->getDocView()->setShowCover( false ); m_ui->crSample->getDocView()->setViewMode( DVM_SCROLL, 1 ); m_ui->crSample->getDocView()->getPageImage(0); HyphMan::getDictList()->activate( qt2cr(m_oldHyph) ); }
Scene2101::Scene2101(NeverhoodEngine *vm, Module *parentModule, int which) : Scene(vm, parentModule) { Sprite *tempSprite; SetMessageHandler(&Scene2101::handleMessage); SetUpdateHandler(&Scene2101::update); setBackground(0x44242305); setPalette(0x44242305); insertScreenMouse(0x4230144A); insertStaticSprite(0x00502330, 1100); tempSprite = insertStaticSprite(0x78492010, 1100); _ssFloorButton = insertSprite<SsCommonFloorButton>(this, 0x72427010, 0x32423010, 200, 0); _asTape1 = insertSprite<AsScene1201Tape>(this, 18, 1100, 412, 443, 0x9148A011); addCollisionSprite(_asTape1); _asTape2 = insertSprite<AsScene1201Tape>(this, 11, 1100, 441, 443, 0x9048A093); addCollisionSprite(_asTape2); if (which < 0) { insertKlaymen<KmScene2101>(380, 438); setMessageList(0x004B8E48); sendMessage(this, 0x2000, 0); _asDoor = insertSprite<AsScene2101Door>(false); _doorStatus = 1; _countdown1 = 0; } else if (which == 1) { // Klaymen entering from the right insertKlaymen<KmScene2101>(640, 438); setMessageList(0x004B8E50); sendMessage(this, 0x2000, 0); _asDoor = insertSprite<AsScene2101Door>(true); _doorStatus = 2; _countdown1 = 48; } else if (which == 2) { // Klaymen teleporting out insertKlaymen<KmScene2101>(115, 438); sendMessage(_klaymen, 0x2000, 1); setMessageList(0x004B8F58); sendMessage(this, 0x2000, 1); _asDoor = insertSprite<AsScene2101Door>(false); _doorStatus = 1; _countdown1 = 0; } else if (which == 3) { // Klaymen returning from the teleporter console insertKlaymen<KmScene2101>(115, 438); sendMessage(_klaymen, 0x2000, 1); setMessageList(0x004B8EB0); sendMessage(this, 0x2000, 1); _asDoor = insertSprite<AsScene2101Door>(false); _doorStatus = 1; _countdown1 = 0; } else { // Klaymen teleporting in insertKlaymen<KmScene2101>(115, 438); sendMessage(_klaymen, 0x2000, 1); setMessageList(0x004B8EA0); sendMessage(this, 0x2000, 1); _asDoor = insertSprite<AsScene2101Door>(false); _doorStatus = 1; _countdown1 = 0; } _asHitByDoorEffect = insertSprite<AsScene2101HitByDoorEffect>(_klaymen); _klaymen->setClipRect(0, 0, tempSprite->getDrawRect().x2(), 480); }
void *MsgViewBase::processEvent(Event *e) { if (e->type() == EventMessageRead){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_HREF); if (n < 0) continue; s = s.mid(n + strlen(MSG_HREF)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); if (id != msg->id()) continue; getToken(s, ','); if (s != msg->client()) continue; int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setSelection(i, 0, i, 0xFFFF); setBold(false); if ((paraFrom == -1) && (paraTo == -1)){ removeSelection(); scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } return NULL; } if (e->type() == EventHistoryConfig){ unsigned id = (unsigned)(e->param()); if (id && (id != m_id)) return NULL; QString t; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_HREF); if (n < 0) continue; s = s.mid(n + strlen(MSG_HREF)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); getToken(s, ','); Message *msg = History::load(id, s.utf8(), m_id); if (msg == NULL) continue; t += messageText(msg); delete msg; } QPoint p = QPoint(0, height()); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); setText(t); setBackground(0); if (pos == -1){ scrollToBottom(); }else{ setCursorPosition(para, pos); ensureCursorVisible(); } } if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: cmd->flags &= ~(COMMAND_DISABLED | COMMAND_CHECKED); if (!hasSelectedText()) cmd->flags |= COMMAND_DISABLED; return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ unsigned type = msg->type(); delete msg; for (;;){ CommandDef *def = CorePlugin::m_plugin->messageTypes.find(type); if (def == NULL){ return NULL; } MessageDef *mdef = (MessageDef*)(def->param); if (mdef->base_type){ type = mdef->base_type; continue; } cmd->icon = def->icon; cmd->flags &= ~COMMAND_CHECKED; return e->param(); } } return NULL; case CmdMsgSpecial: msg = currentMessage(); if (msg){ Event eMenu(EventGetMenuDef, (void*)MenuMsgCommand); CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process()); unsigned n = 0; MessageDef *mdef = NULL; if (msg->getFlags() & MESSAGE_RECEIVED){ unsigned type = msg->type(); for (;;){ CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd == NULL) break; mdef = (MessageDef*)(msgCmd->param); if (mdef->base_type == 0) break; type = mdef->base_type; } } if (mdef && mdef->cmd){ for (const CommandDef *d = mdef->cmd; d->text; d++) n++; } { CommandsList it(*cmdsMsg, true); while (++it) n++; } if (n == 0) return NULL; n++; CommandDef *cmds = new CommandDef[n]; memset(cmds, 0, sizeof(CommandDef) * n); n = 0; if (mdef && mdef->cmd){ for (const CommandDef *d = mdef->cmd; d->text; d++){ cmds[n] = *d; cmds[n].id = CmdMsgSpecial + n; n++; } } CommandDef *c; CommandsList it(*cmdsMsg, true); while ((c = ++it) != NULL){ CommandDef cmd = *c; cmd.menu_id = MenuMsgCommand; cmd.param = msg; Event e(EventCheckState, &cmd); if (!e.process()) continue; cmd.flags &= ~COMMAND_CHECK_STATE; cmds[n++] = cmd; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; delete msg; return e->param(); } return NULL; } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: copy(); return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ Event eOpen(EventOpenMessage, msg); eOpen.process(); delete msg; return e->param(); } return NULL; default: msg = currentMessage(); if (msg){ if (cmd->id >= CmdMsgSpecial){ MessageDef *mdef = NULL; unsigned type = msg->type(); for (;;){ CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd == NULL) break; mdef = (MessageDef*)(msgCmd->param); if (mdef->base_type == 0) break; type = mdef->base_type; } if (mdef && mdef->cmd){ unsigned n = cmd->id - CmdMsgSpecial; for (const CommandDef *d = mdef->cmd; d->text; d++){ if (n-- == 0){ CommandDef cmd = *d; cmd.param = msg; Event eCmd(EventCommandExec, &cmd); eCmd.process(); return e->param(); } } } } Command c; c->id = cmd->id; c->menu_id = MenuMsgCommand; c->param = msg; Event e(EventCommandExec, c); void *res = e.process(); delete msg; return res; } return NULL; } } return NULL; }
void magblocks4(void) { static char command[COMMANDLEN + 2]; static double undoFit[NA], undoFitUnc[NA]; int npnts, j; double qmax, qmin; /* Process command */ while (queryString("magblocks4% ", command, COMMANDLEN + 2) == NULL); caps(command); /* Spawn a command */ if (strcmp(command, "!") == 0 || strcmp(command, "!!") == 0) { bang(command); /* Print current directory */ } else if (strcmp(command, "PWD") == 0) { puts(currentDir); /* Change current directory */ } else if (strcmp(command, "CD") == 0) { cd(command); /* Help */ } else if ( strcmp(command, "?") == 0 || strcmp(command, "HE") == 0 ) { help(command + (*command == '?' ? 1 : 2)); /* Value of vacuum QCSQ */ } else if ( strcmp(command, "QCV") == 0 || strcmp(command, "VQC") == 0 ) { setVQCSQ(qcsq); /* Vacuum QCMSQ */ } else if ( strcmp(command, "QMV") == 0 || strcmp(command, "VQM") == 0 ) { setVMQCSQ(qcmsq); /* Value of vacuum linear absorption coefficient */ } else if ( strcmp(command, "MUV") == 0 || strcmp(command, "VMU") == 0 ) { setVMU(mu); /* Enter critical Q squared */ } else if (strncmp(command, "QC", 2) == 0) { setQCSQ(command + 2, qcsq, Dqcsq); /* Top magnetic critical Q squared */ } else if (strncmp(command, "QM", 2) == 0) { setMQCSQ(command + 2, qcmsq, Dqcmsq); /* Top length absorption coefficient */ } else if (strncmp(command, "MU", 2) == 0) { setMU(command + 2, mu, Dmu); /* Thicknesses of magnetic layers */ } else if (strncmp(command, "DM", 2) == 0) { setDM(command + 2, dm, Ddm); /* Delta lambda */ } else if (strcmp(command, "DL") == 0) { setLamdel(&lamdel); /* Delta theta */ } else if (strcmp(command, "DT") == 0) { setThedel(&thedel); /* Enter chemical thickness */ } else if (command[0] == 'D') { setD(command + 1, d, Dd); /* Chemical roughnesses */ } else if (strncmp(command, "RO", 2) == 0) { setRO(command + 2, rough, Drough); /* Magnetic roughnesses of layers */ } else if (strncmp(command, "RM", 2) == 0) { setMRO(command + 2, mrough, Dmrough); /* Theta angle of average moment in layer */ } else if (strncmp(command, "TH", 2) == 0) { setTHE(command + 2, the, Dthe); /* Wavelength */ } else if (strcmp(command, "WL") == 0) { setWavelength(&lambda); /* Guide angle */ } else if (strcmp(command, "EPS") == 0) { setGuideangle(&aguide); /* Number of layers */ } else if (strcmp(command, "NL") == 0) { if (!setNlayer(&nlayer)) /* Bug found Wed Jun 7 10:38:45 EDT 2000 by KOD */ /* since it starts at 0, correction for vacuum forces zero */ for (j = 1; j <= nlayer; j++) /* Set all absorptions to non-zero values */ if (mu[j] < *mu) mu[j] = *mu + 1.e-20; /* Add or remove layers */ } else if (strcmp(command, "AL") == 0 || strcmp(command, "RL") == 0) { modifyLayers(command); /* Copy layer */ } else if (strcmp(command, "CL") == 0) { copyLayer(command); /* Make superlattice */ } else if (strcmp(command, "SL") == 0) { superLayer(command); /* Maximum number of layers used to simulate rough interface */ } else if (strcmp(command, "NR") == 0) { if (!setNrough(&nrough)) { /* Generate interface profile */ if (nrough < 3) nrough = 11; if (proftyp[0] == 'H') gentanh(nrough, zint, rufint); else generf(nrough, zint, rufint); } /* Specify error function or hyperbolic tangent profile */ } else if (strcmp(command, "PR") == 0) { setProfile(proftyp, PROFTYPLEN + 2); /* Range of Q to be scanned */ } else if (strcmp(command, "QL") == 0) { if (!setQrange(&qmin, &qmax)) { qmina = qmin; qmaxa = qmax; qminb = qmin; qmaxb = qmax; qminc = qmin; qmaxc = qmax; qmind = qmin; qmaxd = qmax; } /* Number of points scanned */ } else if (strcmp(command, "NP") == 0) { if (!setNpnts(&npnts)) { npntsa = npnts; npntsb = npnts; npntsc = npnts; npntsd = npnts; } /* File for input data */ } else if (strcmp(command, "IF") == 0) { setFilename(infile, INFILELEN + 2); /* File for output data */ } else if (strcmp(command, "OF") == 0) { setFilename(outfile, OUTFILELEN + 2); /* File for parameters */ } else if (strcmp(command, "PF") == 0) { setFilename(parfile, PARFILELEN + 2); /* Polarization state */ } else if (strcmp(command, "PS") == 0) { setPolstat(polstat, POLSTATLEN + 2); /* Beam intensity */ } else if (strcmp(command, "BI") == 0) { setBeamIntens(&bmintns, &Dbmintns); /* Background intensity */ } else if (strcmp(command, "BK") == 0) { setBackground(&bki, &Dbki); /* Verify parameters by printing out */ } else if (strncmp(command, "VE", 2) == 0) { printLayers(command); /* Get data from file */ } else if (strcmp(command, "GD") == 0) { loadData(infile, xspin); /* Edit constraints */ } else if (strcmp(command, "EC") == 0) { constrainFunc newmodule; newmodule = newConstraints(constrainScript, constrainModule); if (newmodule != NULL) Constrain = newmodule; /* Reload constrain module */ } else if (strcmp(command, "LC") == 0) { Constrain = loadConstrain(constrainModule); /* Unload constrain module */ } else if (strcmp(command, "ULC") == 0) { Constrain = loadConstrain(NULL); /* Load parameters from parameter file */ } else if (strncmp(command, "LP", 2) == 0) { loadParms(command, parfile, constrainScript, constrainModule); /* Save parameters to parameter file */ } else if (strcmp(command, "SP") == 0) { parms(qcsq, qcmsq, d, dm, rough, mrough, mu, the, MAXLAY, &lambda, &lamdel, &thedel, &aguide, &nlayer, &qmina, &qmaxa, &npntsa, &qminb, &qmaxb, &npntsb, &qminc, &qmaxc, &npntsc, &qmind, &qmaxd, &npntsd, infile, outfile, &bmintns, &bki, listA, &mfit, NA, &nrough, proftyp, polstat, DA, constrainScript, parfile, TRUE); /* List data and fit */ } else if (strcmp(command, "LID") == 0) { listData(); /* Generate logarithm of bare (unconvoluted) reflectivity */ /* or generate reflected amplitude */ } else if (strcmp(command,"GR") == 0 || strcmp(command, "GA") == 0) { genReflect(command); /* Generate and display layer profile */ } else if ( strcmp(command, "GLP") == 0 || strncmp(command, "SLP", 3) == 0 ) { genProfile(command); /* Save values in Q4X and YFIT to OUTFILE */ } else if (strcmp(command, "SV") == 0) { saveTemps(outfile, xspin, y4x, n4x, FALSE); /* Save values in Q4X and YFITA to OUTFILE */ } else if (strcmp(command, "SVA") == 0) { saveTemps(outfile, xspin, yfita, n4x, TRUE); /* Calculate derivative of reflectivity or spin asymmetry with respect */ /* to a fit parameter or save a fit to disk file */ } else if ( strcmp(command, "RD") == 0 || strcmp(command, "SRF") == 0 ) { printDerivs(command, npnts); /* Turn off all varied parameters */ } else if (strcmp(command, "VANONE") == 0) { clearLista(listA); /* Specify which parameters are to be varied in the reflectivity fit */ } else if (strncmp(command, "VA", 2) == 0) { varyParm(command); /* Calculate chi-squared */ } else if ( strcmp(command, "CSR") == 0 || strcmp(command, "CS") == 0 ) { calcChiSq(command); /* Fit reflectivity */ } else if (strncmp(command, "FR", 2) == 0) { for (j = 0; j < NA; j++) { undoFit[j] = A[j]; undoFitUnc[j] = DA[j]; } fitReflec(command); /* Undo last fit */ } else if (strcmp(command, "UF") == 0) { for (j = 0; j < NA; j++) { A[j] = undoFit[j]; DA[j] = undoFitUnc[j]; } /* Exit */ } else if ( strcmp(command, "EX") == 0 || strcmp(command, "EXS") == 0 ) { parms(qcsq, qcmsq, d, dm, rough, mrough, mu, the, MAXLAY, &lambda, &lamdel, &thedel, &aguide, &nlayer, &qmina, &qmaxa, &npntsa, &qminb, &qmaxb, &npntsb, &qminc, &qmaxc, &npntsc, &qmind, &qmaxd, &npntsd, infile, outfile, &bmintns, &bki, listA, &mfit, NA, &nrough, proftyp, polstat, DA, constrainScript, parfile, TRUE); /* Print elapsed CPU time */ if (strcmp(command, "EXS") == 0) system("ps"); exit(0); /* Exit without saving changes */ } else if (strcmp(command, "QU") == 0 || strcmp(command, "QUIT") == 0) { exit(0); /* Plot reflectivity on screen */ } else if (strncmp(command, "PRF", 3) == 0) { plotfit(command, xspin); /* Plot profile on screen */ } else if (strncmp(command, "PLP", 3) == 0) { plotprofile(command, xspin); /* Plot movie of reflectivity change from fit */ } else if (strncmp(command, "MVF", 3) == 0) { fitMovie(command, xspin, undoFit); /* Plot general movie from data file on screen */ } else if (strncmp(command, "MVX", 3) == 0) { arbitraryMovie(command, xspin); /* Plot movie of parameter on screen */ } else if (strncmp(command, "MV", 2) == 0) { oneParmMovie(command, xspin); /* Update constraints */ } else if (strcmp(command, "UC") == 0) { genshift(a, TRUE); /* constrain(a); */ (*Constrain)(FALSE, a, nlayer); genshift(a, FALSE); /* Determine number of points required for resolution extension */ } else if (strcmp(command, "RE") == 0) { calcExtend(xspin); #if 0 /* Dead code --- shadowed by "CD" command earlier */ /* Convolute input raw data set with instrumental resolution */ } else if (strcmp(command, "CD") == 0) { calcConvolve(polstat); #endif /* Send data to other processes. */ } else if (strcmp(command, "SEND") == 0) { ipc_send(command); /* Receive data to other processes. */ } else if (strcmp(command, "RECV") == 0) { ipc_recv(command); /* Faulty input */ } else ERROR("/** Unrecognized command **/"); }
void setBackgroundColor(const QBrush& brush) { setBackground(brush); }
void Plot2D::setBackgroundColor(const QBrush &brush) { setBackground(brush); canvasBrush_ = brush; }
void AMScanEditorModelItem::editorWasClicked() { setBackground(backgrounds_.value("default")); }
void MsgViewBase::update() { if (m_updated.empty()) return; unsigned i; for (i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = m_updated.begin(); it != m_updated.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != m_updated.end()) break; } m_updated.clear(); if (i >= (unsigned)paragraphs()) return; int x = contentsX(); int y = contentsY(); viewport()->setUpdatesEnabled(false); unsigned start = i; list<Msg_Id> msgs; for (; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = msgs.begin(); it != msgs.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != msgs.end()) continue; Msg_Id m_id; m_id.id = id; m_id.client = client; msgs.push_back(m_id); } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setReadOnly(false); setSelection(start, 0, paragraphs() - 1, 0xFFFF, 0); removeSelectedText(); setReadOnly(true); QString text; for (list<Msg_Id>::iterator it = msgs.begin(); it != msgs.end(); ++it){ Message *msg = History::load((*it).id, (*it).client.c_str(), m_id); if (msg == NULL) continue; bool bUnread = false; for (list<msg_id>::iterator itu = CorePlugin::m_plugin->unread.begin(); itu != CorePlugin::m_plugin->unread.end(); ++itu){ msg_id &m = (*itu); if ((m.contact == msg->contact()) && (m.id == msg->id()) && (m.client == msg->client())){ bUnread = true; break; } } text += messageText(msg, bUnread); } viewport()->setUpdatesEnabled(true); append(text); if (!CorePlugin::m_plugin->getOwnColors()) setBackground(i); if ((paraFrom != paraTo) || (indexFrom != indexTo)) setSelection(paraFrom, indexFrom, paraTo, indexTo, 0); TextShow::sync(); setContentsPos(x, y); viewport()->repaint(); }
MenuInventory::MenuInventory(StatBlock *_stats) { stats = _stats; MAX_EQUIPPED = 4; MAX_CARRIED = 64; visible = false; setBackground("images/menus/inventory.png"); currency = 0; carried_cols = 4; // default to 4 if menus/inventory.txt::carried_cols not set carried_rows = 4; // default to 4 if menus/inventory.txt::carried_rows not set drag_prev_src = -1; changed_equipment = true; log_msg = ""; show_book = ""; closeButton = new WidgetButton("images/menus/buttons/button_x.png"); // Load config settings FileParser infile; // @CLASS MenuInventory|Description of menus/inventory.txt if (infile.open("menus/inventory.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR equipment_slot|x (integer), y (integer), size (integer), slot_type (string)|Position and item type of an equipment slot. else if(infile.key == "equipment_slot") { Rect area; Point pos; pos.x = area.x = popFirstInt(infile.val); pos.y = area.y = popFirstInt(infile.val); area.w = area.h = popFirstInt(infile.val); equipped_area.push_back(area); equipped_pos.push_back(pos); slot_type.push_back(popFirstString(infile.val)); } // @ATTR slot_name|string|The displayed name of the last defined equipment slot. else if(infile.key == "slot_name") slot_desc.push_back(infile.val); // @ATTR carried_area|x (integer), y (integer)|Position of the first normal inventory slot. else if(infile.key == "carried_area") { Point pos; carried_pos.x = carried_area.x = popFirstInt(infile.val); carried_pos.y = carried_area.y = popFirstInt(infile.val); } // @ATTR carried_cols|integer|The number of columns for the normal inventory. else if (infile.key == "carried_cols") carried_cols = std::max(1, toInt(infile.val)); // @ATTR carried_rows|integer|The number of rows for the normal inventory. else if (infile.key == "carried_rows") carried_rows = std::max(1, toInt(infile.val)); // @ATTR label_title|label|Position of the "Inventory" label. else if (infile.key == "label_title") title = eatLabelInfo(infile.val); // @ATTR currency|label|Position of the label that displays the total currency being carried. else if (infile.key == "currency") currency_lbl = eatLabelInfo(infile.val); // @ATTR help|x (integer), y (integer), w (integer), h (integer)|A mouse-over area that displays some help text for inventory shortcuts. else if (infile.key == "help") help_pos = toRect(infile.val); else infile.error("MenuInventory: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } MAX_EQUIPPED = equipped_area.size(); MAX_CARRIED = carried_cols * carried_rows; carried_area.w = carried_cols*ICON_SIZE; carried_area.h = carried_rows*ICON_SIZE; color_normal = font->getColor("menu_normal"); color_high = font->getColor("menu_bonus"); inventory[EQUIPMENT].init(MAX_EQUIPPED, equipped_area, slot_type); inventory[CARRIED].init(MAX_CARRIED, carried_area, ICON_SIZE, carried_cols); for (int i = 0; i < MAX_EQUIPPED; i++) { tablist.add(inventory[EQUIPMENT].slots[i]); } for (int i = 0; i < MAX_CARRIED; i++) { tablist.add(inventory[CARRIED].slots[i]); } align(); }
Scene1608::Scene1608(NeverhoodEngine *vm, Module *parentModule, int which) : Scene(vm, parentModule), _asCar(NULL), _countdown1(0) { setGlobalVar(V_CAR_DELTA_X, 1); SetMessageHandler(&Scene1608::hmLowerFloor); _asKey = insertSprite<AsCommonKey>(this, 1, 1100, 198, 220); addCollisionSprite(_asKey); if (which < 0) { // Restoring game if (_vm->gameState().which == 1) // Klaymen is in the car which = 1; else { // Klaymen is standing around setRectList(0x004B47D0); insertKlaymen<KmScene1608>(380, 438); _kmScene1608 = _klaymen; _klaymenInCar = false; _sprite1 = insertStaticSprite(0x7D0404E8, 1100); setMessageList(0x004B46A8); setBackground(0x10080E01); setPalette(0x10080E01); _asTape = insertSprite<AsScene1201Tape>(this, 13, 1100, 412, 443, 0x9148A011); addCollisionSprite(_asTape); _klaymen->setClipRect(_sprite1->getDrawRect().x, 0, 640, 480); SetUpdateHandler(&Scene1608::upLowerFloor); insertScreenMouse(0x80E05108); insertStaticSprite(0x4B18F868, 1200); } } else if (which == 0) { // Klaymen entering from the left _vm->gameState().which = 0; setRectList(0x004B47D0); insertKlaymen<KmScene1608>(0, 438); _kmScene1608 = _klaymen; _klaymenInCar = false; setMessageList(0x004B46B0); setBackground(0x10080E01); setPalette(0x10080E01); _asTape = insertSprite<AsScene1201Tape>(this, 13, 1100, 412, 443, 0x9148A011); addCollisionSprite(_asTape); insertScreenMouse(0x80E05108); _sprite1 = insertStaticSprite(0x7D0404E8, 1100); _klaymen->setClipRect(_sprite1->getDrawRect().x, 0, 640, 480); SetUpdateHandler(&Scene1608::upLowerFloor); insertStaticSprite(0x4B18F868, 1200); } else if (which == 2) { // Klaymen returning from looking through the upper window _vm->gameState().which = 1; _dataResource.load(0x003C0492); _roomPathPoints = _dataResource.getPointArray(calcHash("meArchroArchRoomPath")); setBackground(0x98001604); setPalette(0x98001604); _palette->addPalette("paPodRed", 65, 31, 65); insertScreenMouse(0x01600988); _sprite2 = insertStaticSprite(0x491F38A8, 1100); _asCar = createSprite<AsCommonCar>(this, 375, 227); // Create but don't add to the sprite list yet _asIdleCarLower = insertSprite<AsCommonIdleCarLower>(375, 227); _asIdleCarFull = insertSprite<AsCommonIdleCarFull>(375, 227); _asCar->setVisible(false); if (getGlobalVar(V_KLAYMEN_IS_DELTA_X)) { insertKlaymen<KmScene1608>(373, 220); _klaymen->setDoDeltaX(1); } else insertKlaymen<KmScene1608>(283, 220); _kmScene1608 = _klaymen; setMessageList(0x004B47A8); SetMessageHandler(&Scene1608::hmUpperFloor); SetUpdateHandler(&Scene1608::upUpperFloor); _asCar->setPathPoints(_roomPathPoints); sendMessage(_asCar, 0x2002, _roomPathPoints->size() - 1); _sprite3 = insertStaticSprite(0xB47026B0, 1100); _clipRect1.set(_sprite3->getDrawRect().x, _sprite3->getDrawRect().y, 640, _sprite2->getDrawRect().y2()); _clipRect3.set(_sprite2->getDrawRect().x, _sprite3->getDrawRect().y, 640, _sprite2->getDrawRect().y2()); _clipRect2 = _clipRect1; _clipRect2.y2 = 215; _klaymen->setClipRect(_clipRect1); _asCar->setClipRect(_clipRect1); _asIdleCarLower->setClipRect(_clipRect1); _asIdleCarFull->setClipRect(_clipRect1); _asTape = insertSprite<AsScene1201Tape>(this, 13, 1100, 412, 443, 0x9148A011); addCollisionSprite(_asTape); insertSprite<AsCommonCarConnector>(_asCar)->setClipRect(_clipRect1); _klaymenInCar = false; _carClipFlag = false; _carStatus = 0; setRectList(0x004B4810); } // NOTE: Not in the else because 'which' is set to 1 in the true branch if (which == 1) { // Klaymen riding the car _vm->gameState().which = 1; _dataResource.load(0x003C0492); _roomPathPoints = _dataResource.getPointArray(calcHash("meArchroArchRoomPath")); setBackground(0x98001604); setPalette(0x98001604); _palette->addPalette("paPodRed", 65, 31, 65); insertScreenMouse(0x01600988); _asCar = insertSprite<AsCommonCar>(this, 375, 227); _asIdleCarLower = insertSprite<AsCommonIdleCarLower>(375, 227); _asIdleCarFull = insertSprite<AsCommonIdleCarFull>(375, 227); _sprite2 = insertStaticSprite(0x491F38A8, 1100); _kmScene1608 = createSprite<KmScene1608>(this, 439, 220); sendMessage(_kmScene1608, 0x2032, 1); _kmScene1608->setDoDeltaX(1); SetMessageHandler(&Scene1608::hmRidingCar); SetUpdateHandler(&Scene1608::upRidingCar); _asIdleCarLower->setVisible(false); _asIdleCarFull->setVisible(false); _asCar->setPathPoints(_roomPathPoints); sendMessage(_asCar, 0x2002, 0); sendMessage(_asCar, 0x2008, 90); _sprite3 = insertStaticSprite(0xB47026B0, 1100); _clipRect1.set(_sprite3->getDrawRect().x, _sprite3->getDrawRect().y, 640, _sprite2->getDrawRect().y2()); _clipRect3.set(_sprite2->getDrawRect().x, _sprite3->getDrawRect().y, 640, _sprite2->getDrawRect().y2()); _clipRect2 = _clipRect1; _clipRect2.y2 = 215; _kmScene1608->setClipRect(_clipRect1); _asCar->setClipRect(_clipRect1); _asIdleCarLower->setClipRect(_clipRect1); _asIdleCarFull->setClipRect(_clipRect1); _asTape = insertSprite<AsScene1201Tape>(this, 13, 1100, 412, 443, 0x9148A011); // ... addCollisionSprite(_asTape); insertSprite<AsCommonCarConnector>(_asCar)->setClipRect(_clipRect1); _klaymenInCar = true; _carClipFlag = true; _carStatus = 0; } _palette->addPalette("paKlayRed", 0, 64, 0); }
CustomGameStatsMenu::CustomGameStatsMenu() : MenuBase() { // set up window SDL_Surface *surf; surf = pGFXManager->getUIGraphic(UI_MenuBackground); setBackground(surf,false); resize(surf->w,surf->h); setWindowWidget(&windowWidget); int localHouseColor = houseColor[pLocalHouse->getHouseID()]; windowWidget.addWidget(&mainVBox, Point(24,23), Point(screen->w - 48, screen->h - 32)); captionLabel.setText(getBasename(currentGame->getGameInitSettings().getFilename(), true)); captionLabel.setTextColor(localHouseColor + 3); captionLabel.setAlignment(Alignment_HCenter); mainVBox.addWidget(&captionLabel, 24); mainVBox.addWidget(VSpacer::create(24)); mainVBox.addWidget(Spacer::create(), 0.05); mainVBox.addWidget(&mainHBox, 0.80); mainHBox.addWidget(Spacer::create(), 0.4); mainHBox.addWidget(&playerStatListVBox, 0.2); headerHBox.addWidget(&headerLabelDummy, 130); headerHBox.addWidget(Spacer::create(), 10); headerLabel1.setText(_("Built Object")); headerLabel1.setAlignment(Alignment_HCenter); headerLabel1.setTextColor(localHouseColor + 3); headerHBox.addWidget(&headerLabel1, 132); headerHBox.addWidget(Spacer::create(), 30); headerLabel2.setText(_("Destroyed")); headerLabel2.setAlignment(Alignment_HCenter); headerLabel2.setTextColor(localHouseColor + 3); headerHBox.addWidget(&headerLabel2, 132); headerLabel3.setText(_("Harvested Spice")); headerLabel3.setAlignment(Alignment_HCenter); headerLabel3.setTextColor(localHouseColor + 3); headerHBox.addWidget(Spacer::create(), 30); headerHBox.addWidget(&headerLabel3, 132); playerStatListVBox.addWidget(&headerHBox, 25); playerStatListVBox.addWidget(VSpacer::create(15)); int maxBuiltValue = 0; int maxDestroyedValue = 0; float maxSpiceHarvested = 0.0; for(int i=0;i<NUM_HOUSES;i++) { House* pHouse = currentGame->getHouse(i); if(pHouse != NULL) { maxBuiltValue = std::max(maxBuiltValue, pHouse->getBuiltValue()); maxDestroyedValue = std::max(maxDestroyedValue, pHouse->getDestroyedValue()); maxSpiceHarvested = std::max(maxSpiceHarvested, pHouse->getHarvestedSpice()); } } for(int i=0;i<NUM_HOUSES;i++) { HouseStat& curHouseStat = houseStat[i]; House* pHouse = currentGame->getHouse(i); if(pHouse != NULL) { int color = houseColor[i]; curHouseStat.houseName.setText(_("House") + " " + getHouseNameByNumber((HOUSETYPE) i)); curHouseStat.houseName.setTextColor(color + 3); curHouseStat.houseHBox.addWidget(&curHouseStat.houseName, 140); curHouseStat.houseHBox.addWidget(Spacer::create(), 15); curHouseStat.value1.setText( stringify(pHouse->getBuiltValue()*100)); curHouseStat.value1.setTextFont(FONT_STD10); curHouseStat.value1.setAlignment(Alignment_Right); curHouseStat.value1.setTextColor(color + 3); curHouseStat.houseHBox.addWidget(&curHouseStat.value1, 50); curHouseStat.houseHBox.addWidget(HSpacer::create(2)); curHouseStat.progressBar1.setProgress( (maxBuiltValue == 0) ? 0.0 : (pHouse->getBuiltValue() * 100.0f / maxBuiltValue)); curHouseStat.progressBar1.setDrawShadow(true); curHouseStat.progressBar1.setColor(color + 1); curHouseStat.vBox1.addWidget(Spacer::create(), 0.5); curHouseStat.vBox1.addWidget(&curHouseStat.progressBar1, 12); curHouseStat.vBox1.addWidget(Spacer::create(), 0.5); curHouseStat.houseHBox.addWidget(&curHouseStat.vBox1, 80); curHouseStat.houseHBox.addWidget(Spacer::create(), 30); curHouseStat.value2.setText( stringify(pHouse->getDestroyedValue()*100)); curHouseStat.value2.setTextFont(FONT_STD10); curHouseStat.value2.setAlignment(Alignment_Right); curHouseStat.value2.setTextColor(color + 3); curHouseStat.houseHBox.addWidget(&curHouseStat.value2, 50); curHouseStat.houseHBox.addWidget(HSpacer::create(2)); curHouseStat.progressBar2.setProgress( (maxDestroyedValue == 0) ? 0.0 : (pHouse->getDestroyedValue() * 100.0f / maxDestroyedValue)); curHouseStat.progressBar2.setDrawShadow(true); curHouseStat.progressBar2.setColor(color + 1); curHouseStat.vBox2.addWidget(Spacer::create(), 0.5); curHouseStat.vBox2.addWidget(&curHouseStat.progressBar2, 12); curHouseStat.vBox2.addWidget(Spacer::create(), 0.5); curHouseStat.houseHBox.addWidget(&curHouseStat.vBox2, 80); curHouseStat.houseHBox.addWidget(Spacer::create(), 30); curHouseStat.value3.setText( stringify((int) pHouse->getHarvestedSpice())); curHouseStat.value3.setTextFont(FONT_STD10); curHouseStat.value3.setAlignment(Alignment_Right); curHouseStat.value3.setTextColor(color + 3); curHouseStat.houseHBox.addWidget(&curHouseStat.value3, 50); curHouseStat.houseHBox.addWidget(HSpacer::create(2)); curHouseStat.progressBar3.setProgress( (maxSpiceHarvested == 0.0) ? 0.0 : (pHouse->getHarvestedSpice() * 100.0f / maxSpiceHarvested)); curHouseStat.progressBar3.setDrawShadow(true); curHouseStat.progressBar3.setColor(color + 1); curHouseStat.vBox3.addWidget(Spacer::create(), 0.5); curHouseStat.vBox3.addWidget(&curHouseStat.progressBar3, 12); curHouseStat.vBox3.addWidget(Spacer::create(), 0.5); curHouseStat.houseHBox.addWidget(&curHouseStat.vBox3, 80); playerStatListVBox.addWidget(&curHouseStat.houseHBox, 20); playerStatListVBox.addWidget(VSpacer::create(15)); } } mainHBox.addWidget(Spacer::create(), 0.4); mainVBox.addWidget(Spacer::create(), 0.05); mainVBox.addWidget(VSpacer::create(20)); mainVBox.addWidget(&buttonHBox, 24); mainVBox.addWidget(VSpacer::create(14), 0.0); buttonHBox.addWidget(HSpacer::create(70)); int totalTime = currentGame->getGameTime()/1000; timeLabel.setText(strprintf(_("@DUNE.ENG|22#Time: %d:%02d"), totalTime/3600, (totalTime%3600)/60)); timeLabel.setTextColor(localHouseColor + 3); buttonHBox.addWidget(&timeLabel, 0.2); buttonHBox.addWidget(HSpacer::create(20)); int nbdays = currentGame->getNumberOfDays(); std::string phase = currentGame->getDayPhaseString(); std::string qualif,sepa, daycal, daytext; if (nbdays == 1) { qualif = (_("st")); } else if (nbdays == 2) { qualif = (_("nd")); } else { qualif = (_("th"));; } daycal= (_("on the")); daytext = phase+" "+daycal+" "+ std::to_string(nbdays)+ qualif+sepa; dayLabel.setText(daytext); dayLabel.setTextColor(localHouseColor + 3); if ( currentGame->getGameInitSettings().getGameOptions().daynight ) { buttonHBox.addWidget(&dayLabel, 0.2); } buttonHBox.addWidget(Spacer::create(), 0.0625); buttonHBox.addWidget(Spacer::create(), 0.475); buttonHBox.addWidget(Spacer::create(), 0.0625); okButton.setText(_("OK")); okButton.setTextColor(localHouseColor + 3); okButton.setOnClick(std::bind(&CustomGameStatsMenu::onOK, this)); buttonHBox.addWidget(&okButton, 0.2); buttonHBox.addWidget(HSpacer::create(90)); }
void LCDControllerDriver::clearScreen() { setBackground(0x00000000); }
MenuVendor::MenuVendor(StatBlock *_stats) : Menu() , stats(_stats) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) , tabControl(new WidgetTabControl()) , slots_cols(1) , slots_rows(1) , activetab(VENDOR_BUY) , color_normal(font->getColor("menu_normal")) , npc(NULL) , buyback_stock() { setBackground("images/menus/vendor.png"); tabControl->setTabTitle(VENDOR_BUY, msg->get("Inventory")); tabControl->setTabTitle(VENDOR_SELL, msg->get("Buyback")); // Load config settings FileParser infile; // @CLASS MenuVendor|Description of menus/vendor.txt if(infile.open("menus/vendor.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR slots_area|x (integer), y (integer)|Position of the top-left slot. else if(infile.key == "slots_area") { slots_area.x = popFirstInt(infile.val); slots_area.y = popFirstInt(infile.val); } // @ATTR vendor_cols|integer|The number of columns in the grid of slots. else if (infile.key == "vendor_cols") { slots_cols = std::max(1, toInt(infile.val)); } // @ATTR vendor_rows|integer|The number of rows in the grid of slots. else if (infile.key == "vendor_rows") { slots_rows = std::max(1, toInt(infile.val)); } // @ATTR label_title|label|The position of the text that displays the NPC's name. else if (infile.key == "label_title") { title = eatLabelInfo(infile.val); } else { infile.error("MenuVendor: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } VENDOR_SLOTS = slots_cols * slots_rows; slots_area.w = slots_cols*ICON_SIZE; slots_area.h = slots_rows*ICON_SIZE; stock[VENDOR_BUY].init(VENDOR_SLOTS, slots_area, ICON_SIZE, slots_cols); stock[VENDOR_SELL].init(VENDOR_SLOTS, slots_area, ICON_SIZE, slots_cols); buyback_stock.init(NPC_VENDOR_MAX_STOCK); for (unsigned i = 0; i < VENDOR_SLOTS; i++) { tablist.add(stock[VENDOR_BUY].slots[i]); } for (unsigned i = 0; i < VENDOR_SLOTS; i++) { tablist.add(stock[VENDOR_SELL].slots[i]); } align(); }
MenuStash::MenuStash() : Menu() , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) , tab_control(new WidgetTabControl()) , activetab(STASH_PRIVATE) , drag_prev_tab(-1) , stock() , updated(false) { tab_control->setTabTitle(STASH_PRIVATE, msg->get("Private")); if (!pc->stats.permadeath) tab_control->setTabTitle(STASH_SHARED, msg->get("Shared")); setBackground("images/menus/stash.png"); int slots_cols = 8; // default if menus/stash.txt::stash_cols not set int slots_rows = 8; // default if menus/stash.txt::slots_rows not set // Load config settings FileParser infile; // @CLASS MenuStash|Description of menus/stash.txt if (infile.open("menus/stash.txt", FileParser::MOD_FILE, FileParser::ERROR_NORMAL)) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|point|Position of the close button. if (infile.key == "close") { Point pos = Parse::toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y, Utils::ALIGN_TOPLEFT); } // @ATTR slots_area|point|Position of the top-left slot. else if (infile.key == "slots_area") { slots_area.x = Parse::popFirstInt(infile.val); slots_area.y = Parse::popFirstInt(infile.val); } // @ATTR stash_cols|int|The number of columns for the grid of slots. else if (infile.key == "stash_cols") { slots_cols = std::max(1, Parse::toInt(infile.val)); } // @ATTR stash_rows|int|The number of rows for the grid of slots. else if (infile.key == "stash_rows") { slots_rows = std::max(1, Parse::toInt(infile.val)); } // @ATTR label_title|label|Position of the "Stash" label. else if (infile.key == "label_title") { label_title.setFromLabelInfo(Parse::popLabelInfo(infile.val)); } // @ATTR currency|label|Position of the label displaying the amount of currency stored in the stash. else if (infile.key == "currency") { label_currency.setFromLabelInfo(Parse::popLabelInfo(infile.val)); } else { infile.error("MenuStash: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } label_title.setText(msg->get("Stash")); label_title.setColor(font->getColor(FontEngine::COLOR_MENU_NORMAL)); label_currency.setColor(font->getColor(FontEngine::COLOR_MENU_NORMAL)); int stash_slots = slots_cols * slots_rows; slots_area.w = slots_cols * eset->resolutions.icon_size; slots_area.h = slots_rows * eset->resolutions.icon_size; stock[STASH_PRIVATE].initGrid(stash_slots, slots_area, slots_cols); stock[STASH_SHARED].initGrid(stash_slots, slots_area, slots_cols); tablist.add(tab_control); tablist_private.setPrevTabList(&tablist); tablist_shared.setPrevTabList(&tablist); tablist_private.lock(); tablist_shared.lock(); for (int i = 0; i < stash_slots; i++) { tablist_private.add(stock[STASH_PRIVATE].slots[i]); tablist_shared.add(stock[STASH_SHARED].slots[i]); } align(); }
LoadMapWindow::LoadMapWindow(int color) : Window(0,0,0,0), color(color) { // set up window SDL_Surface *surf; surf = pGFXManager->getUIGraphic(UI_NewMapWindow); setBackground(surf,false); int xpos = std::max(0,(screen->w - surf->w)/2); int ypos = std::max(0,(screen->h - surf->h)/2); setCurrentPosition(xpos,ypos,surf->w,surf->h); setWindowWidget(&mainHBox); mainHBox.addWidget(HSpacer::create(16)); mainHBox.addWidget(&mainVBox); mainHBox.addWidget(HSpacer::create(16)); titleLabel.setTextColor(110, COLOR_TRANSPARENT); titleLabel.setAlignment((Alignment_Enum) (Alignment_HCenter | Alignment_VCenter)); titleLabel.setText(_("Load Map")); mainVBox.addWidget(&titleLabel); mainVBox.addWidget(VSpacer::create(22)); mainVBox.addWidget(¢ralHBox, 346); centralHBox.addWidget(&leftVBox, 0.8); leftVBox.addWidget(&mapTypeButtonsHBox, 24); singleplayerUserMapsButton.setText(_("SP User Maps")); singleplayerUserMapsButton.setTextColor(color); singleplayerUserMapsButton.setToggleButton(true); singleplayerUserMapsButton.setOnClick(std::bind(&LoadMapWindow::onMapTypeChange, this, 0)); mapTypeButtonsHBox.addWidget(&singleplayerUserMapsButton); multiplayerUserMapsButton.setText(_("MP User Maps")); multiplayerUserMapsButton.setTextColor(color); multiplayerUserMapsButton.setToggleButton(true); multiplayerUserMapsButton.setOnClick(std::bind(&LoadMapWindow::onMapTypeChange, this, 1)); mapTypeButtonsHBox.addWidget(&multiplayerUserMapsButton); mapTypeButtonsHBox.addWidget(Spacer::create(), 5.0); mapList.setColor(color); mapList.setAutohideScrollbar(false); mapList.setOnSelectionChange(std::bind(&LoadMapWindow::onMapListSelectionChange, this, std::placeholders::_1)); mapList.setOnDoubleClick(std::bind(&LoadMapWindow::onLoad, this)); leftVBox.addWidget(&mapList, 0.95); leftVBox.addWidget(VSpacer::create(10)); centralHBox.addWidget(HSpacer::create(8)); centralHBox.addWidget(Spacer::create(), 0.05); centralHBox.addWidget(&rightVBox, 180); minimap.setSurface( GUIStyle::getInstance().createButtonSurface(130,130,_("Choose map"), true, false), true); rightVBox.addWidget(&minimap); rightVBox.addWidget(VSpacer::create(10)); rightVBox.addWidget(&mapPropertiesHBox, 0.01); mapPropertiesHBox.addWidget(&mapPropertyNamesVBox, 75); mapPropertiesHBox.addWidget(&mapPropertyValuesVBox, 105); mapPropertyNamesVBox.addWidget(Label::create(_("Size") + ":", color)); mapPropertySize.setTextColor(color); mapPropertyValuesVBox.addWidget(&mapPropertySize); mapPropertyNamesVBox.addWidget(Label::create(_("Players") + ":", color)); mapPropertyPlayers.setTextColor(color); mapPropertyValuesVBox.addWidget(&mapPropertyPlayers); mapPropertyNamesVBox.addWidget(Label::create(_("Author") + ":", color)); mapPropertyAuthors.setTextColor(color); mapPropertyValuesVBox.addWidget(&mapPropertyAuthors); mapPropertyNamesVBox.addWidget(Label::create(_("License") + ":", color)); mapPropertyLicense.setTextColor(color); mapPropertyValuesVBox.addWidget(&mapPropertyLicense); rightVBox.addWidget(Spacer::create()); mainVBox.addWidget(VSpacer::create(5)); mainVBox.addWidget(&buttonHBox); cancelButton.setText(_("Cancel")); cancelButton.setTextColor(color); cancelButton.setOnClick(std::bind(&LoadMapWindow::onCancel, this)); buttonHBox.addWidget(&cancelButton); buttonHBox.addWidget(HSpacer::create(8)); buttonHBox.addWidget(Spacer::create()); buttonHBox.addWidget(HSpacer::create(8)); loadButton.setText(_("Load")); loadButton.setTextColor(color); loadButton.setOnClick(std::bind(&LoadMapWindow::onLoad, this)); buttonHBox.addWidget(&loadButton); mainVBox.addWidget(VSpacer::create(10)); onMapTypeChange(0); }
void MyScene::setBgIndividualy(QString bgPath, int repeat){ //set background setBackground(bgPath, repeat); }
void MsgViewBase::update() { if (m_updated.empty()) return; unsigned i; for (i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = m_updated.begin(); it != m_updated.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != m_updated.end()) break; } m_updated.clear(); if (i >= (unsigned)paragraphs()) return; QPoint p = QPoint(0, 0); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); p = QPoint(0, viewport()->height()); p = viewport()->mapToGlobal(p); p = mapFromGlobal(p); if (p.y() + 2 == height()) pos = -1; unsigned start = i; list<Msg_Id> msgs; for (; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); list<Msg_Id>::iterator it; for (it = msgs.begin(); it != msgs.end(); ++it){ if (((*it).id == id) && ((*it).client == client)) break; } if (it != msgs.end()) continue; Msg_Id m_id; m_id.id = id; m_id.client = client; msgs.push_back(m_id); } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setReadOnly(false); setSelection(start, 0, paragraphs() - 1, 0xFFFF); removeSelectedText(); setReadOnly(true); QString text; for (list<Msg_Id>::iterator it = msgs.begin(); it != msgs.end(); ++it){ Message *msg = History::load((*it).id, (*it).client.c_str(), m_id); if (msg == NULL) continue; bool bUnread = false; for (list<msg_id>::iterator itu = CorePlugin::m_plugin->unread.begin(); itu != CorePlugin::m_plugin->unread.end(); ++itu){ msg_id &m = (*itu); if ((m.contact == msg->contact()) && (m.id == msg->id()) && (m.client == msg->client())){ bUnread = true; break; } } text += messageText(msg, bUnread); } append(text); if (!CorePlugin::m_plugin->getOwnColors()) setBackground(0); if ((paraFrom != paraTo) || (indexFrom != indexTo)) setSelection(paraFrom, indexFrom, paraTo, indexTo); if (pos == -1){ scrollToBottom(); }else{ setCursorPosition(para, pos); ensureCursorVisible(); } }
void TextEdit::bgColorChanged(QColor c) { setBackground(c); emit colorsChanged(); }
void TextShow::resetColors() { setBackground(baseBG); setForeground(baseFG); }
/** * Constructor. */ QG_GraphicView::QG_GraphicView(QWidget* parent, const char* name, Qt::WindowFlags f) : QWidget(parent, f), RS_GraphicView() { setObjectName(name); setBackground(background); redrawMethod=RS2::RedrawAll; isSmoothScrolling = false; PixmapLayer1=PixmapLayer2=PixmapLayer3=NULL; layout = new QGridLayout(this); layout->setMargin(0); layout->setSpacing(0); layout->setColumnStretch(0, 1); layout->setColumnStretch(1, 0); layout->setColumnStretch(2, 0); layout->setRowStretch(0, 1); layout->setRowStretch(1, 0); hScrollBar = new QG_ScrollBar(Qt::Horizontal, this); hScrollBar->setSingleStep(50); hScrollBar->setCursor(Qt::ArrowCursor); layout->addWidget(hScrollBar, 1, 0); layout->addItem(new QSpacerItem(0, hScrollBar->sizeHint().height()), 1, 0); connect(hScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotHScrolled(int))); vScrollBar = new QG_ScrollBar(Qt::Vertical, this); vScrollBar->setSingleStep(50); vScrollBar->setCursor(Qt::ArrowCursor); layout->addWidget(vScrollBar, 0, 2); layout->addItem(new QSpacerItem(vScrollBar->sizeHint().width(), 0), 0, 2); connect(vScrollBar, SIGNAL(valueChanged(int)), this, SLOT(slotVScrolled(int))); // Mouse Cursors: QPixmap cur1(":ui/cur_cad_bmp.png"); QPixmap cur2(":ui/cur_glass_bmp.png"); QPixmap cur3(":ui/cur_del_bmp.png"); QPixmap cur4(":ui/cur_select_bmp.png"); QPixmap cur5(":ui/cur_hand_bmp.png"); #ifdef Q_OS_WIN32 curCad = new QCursor(cur1, 16, 16); curMagnifier = new QCursor(cur2, 12, 12); curDel = new QCursor(cur3, 16, 16); curSelect = new QCursor(cur4, 16, 16); curHand = new QCursor(cur5, 15, 15); #else curCad = new QCursor(cur1, 15, 15); curMagnifier = new QCursor(cur2, 12, 12); curDel = new QCursor(cur3, 15, 15); curSelect = new QCursor(cur4, 15, 15); curHand = new QCursor(cur5, 15, 15); #endif // Dummy widgets for scrollbar corners: //layout->addWidget(new QWidget(this), 1, 1); //QWidget* w = new QWidget(this); //w->setEraseColor(QColor(255,0,0)); gridStatus = new QLabel("-", this); gridStatus->setAlignment(Qt::AlignRight); layout->addWidget(gridStatus, 1, 1, 1, 2); layout->addItem(new QSpacerItem(50, 0), 0, 1); setMouseTracking(true); // flickering under win: //setFocusPolicy(WheelFocus); setFocusPolicy(Qt::NoFocus); // See https://sourceforge.net/tracker/?func=detail&aid=3289298&group_id=342582&atid=1433844 (Left-mouse drag shrinks window) setAttribute(Qt::WA_NoMousePropagation); //update entities to selected entities to the current active layer RS_SETTINGS->beginGroup("/Modify"); m_bUpdateLayer=(RS_SETTINGS->readEntry("/ModifyEntitiesToActiveLayer", "0")=="1"); RS_SETTINGS->writeEntry("/ModifyEntitiesToActiveLayer", m_bUpdateLayer?1:0); RS_SETTINGS->endGroup(); }
void gMainWindow::reparent(gContainer *newpr, int x, int y) { GtkWidget *new_border; int w, h; gColor fg, bg; if (_xembed) return; bg = background(); fg = foreground(); if (isTopLevel() && newpr) { gtk_window_remove_accel_group(GTK_WINDOW(topLevel()->border), accel); new_border = gtk_event_box_new(); gtk_widget_reparent(widget, new_border); embedMenuBar(new_border); _no_delete = true; gtk_widget_destroy(border); _no_delete = false; border = new_border; registerControl(); setCanFocus(false); setParent(newpr); connectParent(); borderSignals(); initWindow(); setBackground(bg); setForeground(fg); setFont(font()); checkMenuBar(); bufX = bufY = 0; move(x, y); gtk_widget_set_size_request(border, width(), height()); // Hidden children are incorrectly shown. Fix that! hideHiddenChildren(); } else if ((!isTopLevel() && !newpr) || (isTopLevel() && isPopup())) //|| (isTopLevel() && (isPopup() ^ (type == GTK_WINDOW_POPUP)))) { gtk_window_remove_accel_group(GTK_WINDOW(topLevel()->border), accel); // TODO: test that new_border = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_reparent(widget, new_border); embedMenuBar(new_border); _no_delete = true; gtk_widget_destroy(border); _no_delete = false; border = new_border; registerControl(); setCanFocus(true); if (parent()) { parent()->remove(this); parent()->arrange(); setParent(NULL); } initWindow(); borderSignals(); setBackground(bg); setForeground(fg); setFont(font()); move(x, y); w = width(); h = height(); bufW = bufH = -1; gtk_widget_set_size_request(border, 1, 1); resize(w, h); hideHiddenChildren(); _popup = false; //type == GTK_WINDOW_POPUP; } else { gContainer::reparent(newpr, x, y); } }
void ComposerEngine::loadLibrary(uint id) { if (getGameType() == GType_ComposerV1 && !_libraries.empty()) { // kill the previous page, starting with any scripts running on it for (Common::List<OldScript *>::iterator i = _oldScripts.begin(); i != _oldScripts.end(); i++) delete *i; _oldScripts.clear(); Library *library = &_libraries.front(); unloadLibrary(library->_id); } Common::String filename; if (getGameType() == GType_ComposerV1) { if (!id || _bookGroup.empty()) filename = getStringFromConfig("Common", "StartPage"); else filename = getStringFromConfig(_bookGroup, Common::String::format("%d", id)); filename = mangleFilename(filename); // bookGroup is the basename of the path. // TODO: tidy this up. _bookGroup.clear(); for (uint i = 0; i < filename.size(); i++) { if (filename[i] == '~' || filename[i] == '/' || filename[i] == ':') continue; for (uint j = 0; j < filename.size(); j++) { if (filename[j] == '/') { _bookGroup.clear(); continue; } if (filename[j] == '.') break; _bookGroup += filename[j]; } break; } } else { if (!id) id = atoi(getStringFromConfig("Common", "StartUp").c_str()); filename = getFilename("Libs", id); } Library library; library._id = id; library._archive = new ComposerArchive(); if (!library._archive->openFile(filename)) error("failed to open '%s'", filename.c_str()); _libraries.push_front(library); Library &newLib = _libraries.front(); Common::Array<uint16> buttonResources = library._archive->getResourceIDList(ID_BUTN); for (uint i = 0; i < buttonResources.size(); i++) { uint16 buttonId = buttonResources[i]; Common::SeekableReadStream *stream = library._archive->getResource(ID_BUTN, buttonId); Button button(stream, buttonId, getGameType()); bool inserted = false; for (Common::List<Button>::iterator b = newLib._buttons.begin(); b != newLib._buttons.end(); b++) { if (button._zorder < b->_zorder) continue; newLib._buttons.insert(b, button); inserted = true; break; } if (!inserted) newLib._buttons.push_back(button); } Common::Array<uint16> ambientResources = library._archive->getResourceIDList(ID_AMBI); for (uint i = 0; i < ambientResources.size(); i++) { Common::SeekableReadStream *stream = library._archive->getResource(ID_AMBI, ambientResources[i]); Button button(stream); newLib._buttons.insert(newLib._buttons.begin(), button); } Common::Array<uint16> accelResources = library._archive->getResourceIDList(ID_ACEL); for (uint i = 0; i < accelResources.size(); i++) { Common::SeekableReadStream *stream = library._archive->getResource(ID_ACEL, accelResources[i]); KeyboardHandler handler; handler.keyId = stream->readUint16LE(); handler.modifierId = stream->readUint16LE(); handler.scriptId = stream->readUint16LE(); newLib._keyboardHandlers.push_back(handler); } Common::Array<uint16> randResources = library._archive->getResourceIDList(ID_RAND); for (uint i = 0; i < randResources.size(); i++) { Common::SeekableReadStream *stream = library._archive->getResource(ID_RAND, randResources[i]); Common::Array<RandomEvent> &events = _randomEvents[randResources[i]]; uint16 count = stream->readUint16LE(); for (uint j = 0; j < count; j++) { RandomEvent random; random.scriptId = stream->readUint16LE(); random.weight = stream->readUint16LE(); events.push_back(random); } delete stream; } // add background sprite, if it exists if (hasResource(ID_BMAP, 1000)) setBackground(1000); // TODO: better CTBL logic loadCTBL(1000, 100); // Run the startup script. runScript(1000, 0, 0, 0); _mouseEnabled = true; onMouseMove(_lastMousePos); runEvent(kEventLoad, id, 0, 0); }
MenuTalker::MenuTalker(MenuManager *_menu) : Menu() , menu(_menu) , portrait(NULL) , dialog_node(0) , event_cursor(0) , font_who("font_regular") , font_dialog("font_regular") , color_normal(font->getColor("menu_normal")) , npc(NULL) , advanceButton(new WidgetButton("images/menus/buttons/right.png")) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) { setBackground("images/menus/dialog_box.png"); // Load config settings FileParser infile; // @CLASS MenuTalker|Description of menus/talker.txt if(infile.open("menus/talker.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR advance|x (integer), y (integer)|Position of the button to advance dialog. else if(infile.key == "advance") { Point pos = toPoint(infile.val); advanceButton->setBasePos(pos.x, pos.y); } // @ATTR dialogbox|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the text box graphics. else if (infile.key == "dialogbox") dialog_pos = toRect(infile.val); // @ATTR dialogtext|x (integer), y (integer), w (integer), h (integer)|Rectangle where the dialog text is placed. else if (infile.key == "dialogtext") text_pos = toRect(infile.val); // @ATTR text_offset|x (integer), y (integer)|Margins for the left/right and top/bottom of the dialog text. else if (infile.key == "text_offset") text_offset = toPoint(infile.val); // @ATTR portrait_he|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the NPC portrait graphics. else if (infile.key == "portrait_he") portrait_he = toRect(infile.val); // @ATTR portrait_you|x (integer), y (integer), w (integer), h (integer)|Position and dimensions of the player's portrait graphics. else if (infile.key == "portrait_you") portrait_you = toRect(infile.val); // @ATTR font_who|string|Font style to use for the name of the currently talking person. else if (infile.key == "font_who") font_who = infile.val; // @ATTR font_dialog|string|Font style to use for the dialog text. else if (infile.key == "font_dialog") font_dialog = infile.val; else infile.error("MenuTalker: '%s' is not a valid key.", infile.key.c_str()); } infile.close(); } label_name = new WidgetLabel(); label_name->setBasePos(text_pos.x + text_offset.x, text_pos.y + text_offset.y); textbox = new WidgetScrollBox(text_pos.w, text_pos.h-(text_offset.y*2)); textbox->setBasePos(text_pos.x, text_pos.y + text_offset.y); tablist.add(advanceButton); tablist.add(closeButton); tablist.add(textbox); align(); }
void MyTreeWidgetItem::setBackgroundInvalid(){ bgColor->setAvailable(true); setBGColor(new Color(QColor(-1,-1,-1,-1))); setBackground(0,Qt::NoBrush); }
SinglePlayerSkirmishMenu::SinglePlayerSkirmishMenu() : MenuBase(), currentGameOptions(settings.gameOptions) { currentHouseChoiceScrollPos = 0; selectedButton = 1; mission = 1; // set up window SDL_Surface *surf, *surfPressed; surf = pGFXManager->getUIGraphic(UI_MenuBackground); setBackground(surf,false); resize(surf->w,surf->h); setWindowWidget(&windowWidget); // set up pictures in the background surf = pGFXManager->getUIGraphic(UI_DuneLegacy); duneLegacy.setSurface(surf,false); windowWidget.addWidget(&duneLegacy, Point((screen->w - surf->w)/2, screen->h/2 + 28), Point(surf->w,surf->h)); surf = pGFXManager->getUIGraphic(UI_MenuButtonBorder); buttonBorder.setSurface(surf,false); windowWidget.addWidget(&buttonBorder, Point((screen->w - surf->w)/2, screen->h/2 + 59), Point(surf->w,surf->h)); // set up menu buttons windowWidget.addWidget(&menuButtonsVBox,Point((screen->w - 160)/2,screen->h/2 + 64), Point(160,111)); startButton.setText(_("Start")); startButton.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onStart, this)); menuButtonsVBox.addWidget(&startButton); startButton.setActive(); menuButtonsVBox.addWidget(VSpacer::create(25)); gameOptionsButton.setText(_("Game Options")); gameOptionsButton.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onGameOptions, this)); menuButtonsVBox.addWidget(&gameOptionsButton, 25); menuButtonsVBox.addWidget(VSpacer::create(25)); backButton.setText(_("Back")); backButton.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onCancel, this)); menuButtonsVBox.addWidget(&backButton); // set up house choice surf = pGFXManager->getUIGraphic(UI_HouseSelect); windowWidget.addWidget(&houseChoiceContainer, Point((screen->w - surf->w)/2,screen->h/2 - surf->h + 10), Point(surf->w,surf->h)); heraldPicture.setSurface(surf,false); houseChoiceContainer.addWidget(&heraldPicture, Point(0,0), Point(surf->w,surf->h)); // House1 button houseChoiceContainer.addWidget( &house1Picture, Point(21,54), Point(83,91)); houseChoiceContainer.addWidget( &house1SelectedPicture, Point(20,53), Point(83,91)); house1Button.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onSelectHouseButton, this, 0)); houseChoiceContainer.addWidget( &house1Button, Point(20,53), Point(83,91)); // House2 button houseChoiceContainer.addWidget( &house2Picture, Point(117,54), Point(83,91)); houseChoiceContainer.addWidget( &house2SelectedPicture, Point(116,53), Point(83,91)); house2Button.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onSelectHouseButton, this, 1)); houseChoiceContainer.addWidget( &house2Button, Point(116,53), Point(83,91)); // House3 button houseChoiceContainer.addWidget( &house3Picture, Point(215,54), Point(83,91)); houseChoiceContainer.addWidget( &house3SelectedPicture, Point(214,53), Point(83,91)); house3Button.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onSelectHouseButton, this, 2)); houseChoiceContainer.addWidget( &house3Button, Point(214,53), Point(83,91)); surf = pGFXManager->getUIGraphic(UI_Herald_ArrowLeft); surfPressed = pGFXManager->getUIGraphic(UI_Herald_ArrowLeftHighlight); houseLeftButton.setSurfaces(surf, false, surf, false, surfPressed, false); houseLeftButton.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onHouseLeft, this)); houseLeftButton.setVisible(false); houseChoiceContainer.addWidget( &houseLeftButton, Point(houseChoiceContainer.getSize().x/2 - surf->w - 85, 160), Point(surf->w,surf->h)); surf = pGFXManager->getUIGraphic(UI_Herald_ArrowRight); surfPressed = pGFXManager->getUIGraphic(UI_Herald_ArrowRightHighlight); houseRightButton.setSurfaces(surf, false, surf, false, surfPressed, false); houseRightButton.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onHouseRight, this)); houseChoiceContainer.addWidget( &houseRightButton, Point(houseChoiceContainer.getSize().x/2 + 85, 160), Point(surf->w,surf->h)); updateHouseChoice(); onSelectHouseButton(1); // setup +/- Buttons to select misson missionCounter.setCount(mission); windowWidget.addWidget( &missionCounter, Point(((screen->w/4)*3 + 160/4) - 83/2,screen->h/2 + 89), missionCounter.getMinimumSize()); surf = pGFXManager->getUIGraphic(UI_Plus); surfPressed = pGFXManager->getUIGraphic(UI_Plus_Pressed); missionPlusButton.setSurfaces(surf,false,surfPressed,false); missionPlusButton.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onMissionIncrement, this)); windowWidget.addWidget( &missionPlusButton, Point(((screen->w/4)*3 + 160/4) - surf->w/2 + 72,screen->h/2 + 96), Point(surf->w,surf->h)); surf = pGFXManager->getUIGraphic(UI_Minus); surfPressed = pGFXManager->getUIGraphic(UI_Minus_Pressed); missionMinusButton.setSurfaces(surf,false,surfPressed,false); missionMinusButton.setOnClick(std::bind(&SinglePlayerSkirmishMenu::onMissionDecrement, this)); windowWidget.addWidget( &missionMinusButton, Point(((screen->w/4)*3 + 160/4) - surf->w/2 + 72,screen->h/2 + 109), Point(surf->w,surf->h)); }
MenuStash::MenuStash(StatBlock *_stats) : Menu() , stats(_stats) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) , color_normal(font->getColor("menu_normal")) , stock() , updated(false) { setBackground("images/menus/stash.png"); slots_cols = 8; // default if menus/stash.txt::stash_cols not set slots_rows = 8; // default if menus/stash.txt::slots_rows not set // Load config settings FileParser infile; // @CLASS MenuStash|Description of menus/stash.txt if (infile.open("menus/stash.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|x (integer), y (integer)|Position of the close button. if (infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR slots_area|x (integer), y (integer)|Position of the top-left slot. else if (infile.key == "slots_area") { slots_area.x = popFirstInt(infile.val); slots_area.y = popFirstInt(infile.val); } // @ATTR stash_cols|integer|The number of columns for the grid of slots. else if (infile.key == "stash_cols") { slots_cols = std::max(1, toInt(infile.val)); } // @ATTR stash_rows|integer|The number of rows for the grid of slots. else if (infile.key == "stash_rows") { slots_rows = std::max(1, toInt(infile.val)); } // @ATTR label_title|label|Position of the "Stash" label. else if (infile.key == "label_title") { title = eatLabelInfo(infile.val); } // @ATTR currency|label|Position of the label displaying the amount of currency stored in the stash. else if (infile.key == "currency") { currency = eatLabelInfo(infile.val); } else { infile.error("MenuStash: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } STASH_SLOTS = slots_cols * slots_rows; slots_area.w = slots_cols*ICON_SIZE; slots_area.h = slots_rows*ICON_SIZE; stock.init( STASH_SLOTS, slots_area, ICON_SIZE, slots_cols); for (int i = 0; i < STASH_SLOTS; i++) { tablist.add(stock.slots[i]); } align(); }
BackgroundWidget::BackgroundWidget(QWidget * parent) : QWidget(parent), background_(0), isUpdatingFromBackground_(false), isBeingEdited_(false) { // Layout QFormLayout * layout = new QFormLayout(); setLayout(layout); // Color colorSelector_ = new ColorSelector(Qt::white); colorSelector_->setToolTip(tr("Set background color")); colorSelector_->setStatusTip(tr("Set background color, possibly transparent.")); layout->addRow(tr("Color:"), colorSelector_); connect(colorSelector_, SIGNAL(colorChanged(Color)), this, SLOT(processColorSelectorColorChanged_(Color))); // Images imageLineEdit_ = new QLineEdit(); imageLineEdit_->setValidator(new BackgroundUrlValidator(imageLineEdit_)); imageLineEdit_->setToolTip(tr("Set background image(s) url\n\n" "Example 1: 'image.png' for the same image at all frames\n" "Example 2: 'image*.png' for 'image2.png' on frame 2, etc.")); imageLineEdit_->setStatusTip(tr("Set background image(s) url. For example, set " "'image.png' for a fixed image shared across all frames, " ", or set 'image*.png' for 'image1.png' at frame 1, " "'image2.png' at frame 2, etc. Paths must be relative to " "where the vec file is saved.")); imageBrowseButton_ = new QPushButton("..."); imageBrowseButton_->setToolTip(tr("Browse for background image(s)")); imageBrowseButton_->setStatusTip(tr("Browse for background image(s). Select two or more files, " "and a pattern of the form 'image*.png' will be automatically " "detected, loading all images matching patterns even if not selected.")); imageBrowseButton_->setMaximumWidth(30); imageRefreshButton_ = new QPushButton(QIcon(":/images/refresh.png"), tr("")); imageRefreshButton_->setToolTip(tr("Reload background image(s)")); imageRefreshButton_->setStatusTip(tr("Reload background image(s) to reflect changes on disk.")); imageRefreshButton_->setMaximumWidth(30); QHBoxLayout * imagesLayout = new QHBoxLayout(); imagesLayout->setSpacing(0); imagesLayout->addWidget(imageLineEdit_); imagesLayout->addWidget(imageBrowseButton_); imagesLayout->addWidget(imageRefreshButton_); layout->addRow(tr("Image(s):"), imagesLayout); connect(imageLineEdit_, SIGNAL(editingFinished()), this, SLOT(processImageLineEditEditingFinished_())); connect(imageBrowseButton_, SIGNAL(clicked(bool)), this, SLOT(processImageBrowseButtonClicked_())); connect(imageRefreshButton_, SIGNAL(clicked(bool)), this, SLOT(processImageRefreshButtonClicked_())); // Position leftSpinBox_ = new QDoubleSpinBox(); leftSpinBox_->setToolTip(tr("X coordinate of top-left corner of background image(s)")); leftSpinBox_->setStatusTip(tr("Set the X coordinate of the position of the top-left corner of background image(s).")); leftSpinBox_->setMaximumWidth(80); leftSpinBox_->setMinimum(-1e6); leftSpinBox_->setMaximum(1e6); topSpinBox_ = new QDoubleSpinBox(); topSpinBox_->setToolTip(tr("Y coordinate of top-left corner of background image(s)")); topSpinBox_->setStatusTip(tr("Set the Y coordinate of the position of the top-left corner of background image(s).")); topSpinBox_->setMaximumWidth(80); topSpinBox_->setMinimum(-1e6); topSpinBox_->setMaximum(1e6); QHBoxLayout * positionLayout = new QHBoxLayout(); positionLayout->addWidget(leftSpinBox_); positionLayout->addWidget(topSpinBox_); layout->addRow(tr("Position:"), positionLayout); connect(leftSpinBox_, SIGNAL(valueChanged(double)), this, SLOT(processLeftSpinBoxValueChanged_(double))); connect(topSpinBox_, SIGNAL(valueChanged(double)), this, SLOT(processTopSpinBoxValueChanged_(double))); connect(leftSpinBox_, SIGNAL(editingFinished()), this, SLOT(processLeftSpinBoxEditingFinished_())); connect(topSpinBox_, SIGNAL(editingFinished()), this, SLOT(processTopSpinBoxEditingFinished_())); // Size sizeComboBox_ = new QComboBox(); sizeComboBox_->setToolTip(tr("Set size of background image(s)")); sizeComboBox_->setStatusTip(tr("Set the size of background image(s).")); sizeComboBox_->addItem(tr("Fit to canvas")); sizeComboBox_->addItem(tr("Manual")); sizeComboBox_->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred)); widthSpinBox_ = new QDoubleSpinBox(); widthSpinBox_->setToolTip(tr("Width of background image(s)")); widthSpinBox_->setStatusTip(tr("Set width of background image(s).")); widthSpinBox_->setMaximumWidth(80); widthSpinBox_->setMinimum(-1e6); widthSpinBox_->setMaximum(1e6); widthSpinBox_->setValue(1280); heightSpinBox_ = new QDoubleSpinBox(); heightSpinBox_->setToolTip(tr("Height of background image(s)")); heightSpinBox_->setStatusTip(tr("Set height of background image(s).")); heightSpinBox_->setMaximumWidth(80); heightSpinBox_->setMinimum(-1e6); heightSpinBox_->setMaximum(1e6); heightSpinBox_->setValue(720); QGridLayout * sizeLayout = new QGridLayout(); sizeLayout->addWidget(sizeComboBox_, 0, 0, 1, 2); sizeLayout->addWidget(widthSpinBox_, 1, 0); sizeLayout->addWidget(heightSpinBox_, 1, 1); layout->addRow(tr("Size:"), sizeLayout); connect(sizeComboBox_, SIGNAL(currentIndexChanged(int)), this, SLOT(processSizeComboBoxCurrentIndexChanged_(int))); connect(widthSpinBox_, SIGNAL(valueChanged(double)), this, SLOT(processWidthSpinBoxValueChanged_(double))); connect(heightSpinBox_, SIGNAL(valueChanged(double)), this, SLOT(processHeightSpinBoxValueChanged_(double))); connect(widthSpinBox_, SIGNAL(editingFinished()), this, SLOT(processWidthSpinBoxEditingFinished_())); connect(heightSpinBox_, SIGNAL(editingFinished()), this, SLOT(processHeightSpinBoxEditingFinished_())); // Repeat repeatComboBox_ = new QComboBox(); repeatComboBox_->setToolTip(tr("Repeat background image(s)")); repeatComboBox_->setStatusTip(tr("Set whether background image(s) should " "be repeated, either horizontally, vertically, or both")); repeatComboBox_->addItem(tr("No")); repeatComboBox_->addItem(tr("Horizontally")); repeatComboBox_->addItem(tr("Vertically")); repeatComboBox_->addItem(tr("Both")); repeatComboBox_->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred)); layout->addRow(tr("Repeat:"), repeatComboBox_); connect(repeatComboBox_, SIGNAL(currentIndexChanged(int)), this, SLOT(processRepeatComboBoxCurrentIndexChanged_(int))); // Opacity opacitySpinBox_ = new QDoubleSpinBox(); opacitySpinBox_->setToolTip(tr("Opacity of background image(s)")); opacitySpinBox_->setStatusTip(tr("Set the opacity of background image(s). Note: this does " "not affect the opacity of the background color (use an alpha " "value for the color instead).")); opacitySpinBox_->setMaximumWidth(80); opacitySpinBox_->setMinimum(0); opacitySpinBox_->setMaximum(1); opacitySpinBox_->setSingleStep(0.1); opacitySpinBox_->setValue(1.0); layout->addRow(tr("Opacity:"), opacitySpinBox_); connect(opacitySpinBox_, SIGNAL(valueChanged(double)), this, SLOT(processOpacitySpinBoxValueChanged_(double))); connect(opacitySpinBox_, SIGNAL(editingFinished()), this, SLOT(processOpacitySpinBoxEditingFinished_())); // Hold holdCheckBox_ = new QCheckBox(); holdCheckBox_->setToolTip(tr("Hold background image(s)")); holdCheckBox_->setStatusTip(tr("Set whether to hold background image(s). Example: 'image*.png'" " with only 'image01.png' and 'image03.png' on disk. At " "frame 2, if hold is checked, 'image01.png' appears. If hold is " "not checked, no image appears, unless 'image.png' exists in which " "case it is used as a fallback value.")); holdCheckBox_->setChecked(true ); layout->addRow(tr("Hold:"), holdCheckBox_); connect(holdCheckBox_, SIGNAL(toggled(bool)), this, SLOT(processHoldCheckBoxToggled_(bool))); // Set no background setBackground(0); }