void Scroller::scrollSongText() { curCharIxSave2 = curCharIx; curCharBitSave2 = curCharBit; writeRedColumns(); for (int j = 0; j < ledRows; j++) { byte outputByte = 0; setCharacter(); curCharIxSave = curCharIx; curCharBitSave = curCharBit; if (reverse) { shiftLeft(j, &outputByte); } else { shiftRight(j, &outputByte); } sendDoubleByteToMax(j + 1, outputByte); curCharIx = curCharIxSave; curCharBit = curCharBitSave; } curCharIx = curCharIxSave2; curCharBit = curCharBitSave2; setCharacter(); advanceBitAndValidate(); updateRedColumn(); }
bool LVL_Player::init() { if(!setCharacter(characterID, stateID)) return false; m_direction = data.direction; long posX = data.x + (data.w / 2) - (state_cur.width / 2); long posY = data.y = data.y + data.h - state_cur.height; setSize(state_cur.width, state_cur.height); setPos(posX, posY); phys_setup.max_vel_y = 12; m_animator.tickAnimation(0.0); m_isLocked = false; if(m_isLuaPlayer) { try { lua_onInit(); } catch(luabind::error &e) { m_scene->getLuaEngine()->postLateShutdownError(e); return false; } } m_isInited = true; _syncSection(); m_momentum.saveOld(); return true; }
void EquipMenu::tabChanged(const std::string& tabName) { if(tabName == "Party") { finished = true; } else { setCharacter(tabName); } }
void LVL_Player::setPlayerPointInfo(PlayerPoint pt) { data = pt; playerID = static_cast<int>(pt.id); PlayerState x = m_scene->getGameState()->getPlayerState(playerID); characterID = x.characterID; stateID = x._chsetup.state; m_health = static_cast<int>(x._chsetup.health); if(m_global_state) m_global_state->setHealth(m_health); if(m_isInited) setCharacter(characterID, stateID); }
void Game::receiveGameInfo(QStringList loginInfo) { playerUsername = loginInfo[0]; setCharacter(loginInfo[3].toInt()); //parse string to int? if(loginInfo[4].compare("1") == 0)//hillary { candidatesDefeated[2] = true; } else { candidatesDefeated[2] = false; } if(loginInfo[5].compare("1") == 0)//cruz { candidatesDefeated[4] = true; } else { candidatesDefeated[4] = false; } if(loginInfo[6].compare("1") == 0)//kasich { candidatesDefeated[3] = true; } else { candidatesDefeated[3] = false; } if(loginInfo[7].compare("1") == 0)//bernie { candidatesDefeated[0] = true; } else { candidatesDefeated[0] = false; } if(loginInfo[8].compare("1") == 0)//trump { candidatesDefeated[1] = true; } else { candidatesDefeated[1] = false; } emit resetStageColors(); }
void RKVariable::rCommandDone (RCommand *command) { RK_TRACE (OBJECTS); if (command->getFlags () == ROBJECT_UDPATE_STRUCTURE_COMMAND) { RObject::rCommandDone (command); } else if (command->getFlags () == GET_DATA_COMMAND) { RK_ASSERT (myData ()); // prevent resyncing of data setSyncing (false); RK_ASSERT (command->getDataType () == RData::StructureVector); RK_ASSERT (command->getDataLength () == 3); RData *data = command->getStructureVector ()[0]; RData *levels = command->getStructureVector ()[1]; RData *invalids = command->getStructureVector ()[2]; // set factor levels first RK_ASSERT (levels->getDataType () == RData::StringVector); unsigned int levels_len = levels->getDataLength (); RK_ASSERT (levels_len >= 1); delete myData ()->value_labels; myData ()->value_labels = new RObject::ValueLabels; if ((levels_len == 1) && levels->getStringVector ()[0].isEmpty ()) { // no levels } else { for (unsigned int i=0; i < levels_len; ++i) { myData ()->value_labels->insert (QString::number (i+1), levels->getStringVector ()[i]); } } // now set the data RK_ASSERT (data->getDataLength () == (unsigned int) getLength ()); // not a problem due to the line below, I'd still like to know if / when this happens. extendToLength (data->getDataLength ()); if (data->getDataType () == RData::StringVector) { setCharacter (0, getLength () - 1, data->getStringVector ()); } else if (data->getDataType () == RData::RealVector) { setNumeric (0, getLength () - 1, data->getRealVector ()); } else if (data->getDataType () == RData::IntVector) { unsigned int len = getLength (); double *dd = new double[len]; for (unsigned int i = 0; i < len; ++i) { if (data->getIntVector ()[i] == INT_MIN) dd[i] = NAN; else dd[i] = (double) data->getIntVector ()[i]; } setNumeric (0, getLength () - 1, dd); delete [] dd; } // now set the invalid fields (only if they are still NAs in the R data) myData ()->invalid_fields.clear (); if (invalids->getDataLength () <= 1) { // no invalids } else { RK_ASSERT (invalids->getDataType () == RData::StringVector); unsigned int invalids_length = invalids->getDataLength (); RK_ASSERT ((invalids_length % 2) == 0); unsigned int invalids_count = invalids_length / 2; for (unsigned int i=0; i < invalids_count; ++i) { int row = invalids->getStringVector ()[i].toInt () - 1; if (myData ()->cell_states[row] & RKVarEditData::NA) { setText (row, invalids->getStringVector ()[invalids_count + i]); } } } myData ()->formatting_options = parseFormattingOptionsString (getMetaProperty ("format")); ChangeSet *set = new ChangeSet; set->from_index = 0; set->to_index = getLength (); RKGlobals::tracker ()->objectDataChanged (this, set); RKGlobals::tracker ()->objectMetaChanged (this); myData ()->dirty = false; setSyncing (true); } else { RK_ASSERT (false); } }
Player::Player() { setCharacter(30,30,5,3,5); }
Variant::Variant(char character) { setCharacter( character ); }
void LVL_Player::update(float ticks) { if(isLocked) return; if(!_isInited) return; if(!camera) return; LVL_Section* section = sct(); if(!section) return; event_queue.processEvents(ticks); if((isWarping) || (!isAlive)) { animator.tickAnimation(ticks); updateCamera(); return; } _onGround = !foot_contacts_map.isEmpty(); on_slippery_surface = !foot_sl_contacts_map.isEmpty(); bool climbableUp = !climbable_map.isEmpty(); bool climbableDown= climbableUp && !_onGround; climbing = (climbableUp && climbing && !_onGround && (posRect.center().y()>=(climbableHeight-physics_cur.velocity_climb_y_up)) ); if(_onGround) { phys_setup.decelerate_x = (fabs(speedX())<=physics_cur.MaxSpeed_walk)? (on_slippery_surface?physics_cur.decelerate_stop/physics_cur.slippery_c : physics_cur.decelerate_stop): (on_slippery_surface?physics_cur.decelerate_run/physics_cur.slippery_c : physics_cur.decelerate_run); if(physics_cur.strict_max_speed_on_ground) { if((speedX()>0)&&(speedX()>phys_setup.max_vel_x)) setSpeedX(phys_setup.max_vel_x); else if((speedX()<0)&&(speedX()<phys_setup.min_vel_x)) setSpeedX(phys_setup.min_vel_x); } } else phys_setup.decelerate_x = physics_cur.decelerate_air; if(doKill) { doKill=false; isAlive = false; setPaused(true); LvlSceneP::s->checkPlayers(); return; } if(climbing) { PGE_Phys_Object* climbableItem = static_cast<PGE_Phys_Object*>((void*)(intptr_t)climbable_map[climbable_map.keys().first()]); if(climbableItem) { _velocityX_add=climbableItem->speedX(); _velocityY_add=climbableItem->speedY(); } else { _velocityX_add=0.0f; _velocityY_add=0.0f; } if(gscale_Backup != 1) { setGravityScale(0); gscale_Backup = 1; } } else { if(gscale_Backup != 0.f) { setGravityScale(physics_cur.gravity_scale); gscale_Backup = 0.f; } } if(climbing) { setSpeed(0,0); } if(environments_map.isEmpty()) { if(last_environment!=section->getPhysicalEnvironment() ) { environment = section->getPhysicalEnvironment(); } } else { int newEnv = section->getPhysicalEnvironment(); foreach(int x, environments_map) { newEnv = x; } if(last_environment != newEnv) { qDebug()<<"Enter to environment" << newEnv; environment = newEnv; } } refreshEnvironmentState(); if(_onGround) { if(!floating_isworks) { floating_timer=floating_maxtime; } } //Running key if(keys.run) { if(!_isRunning) { phys_setup.max_vel_x = physics_cur.MaxSpeed_run; phys_setup.min_vel_x = -physics_cur.MaxSpeed_run; _isRunning=true; } } else { if(_isRunning) { phys_setup.max_vel_x = physics_cur.MaxSpeed_walk; phys_setup.min_vel_x = -physics_cur.MaxSpeed_walk; _isRunning=false; } } if((physics_cur.ground_c_max!=1.0f)) { phys_setup.max_vel_x = fabs(_isRunning ? physics_cur.MaxSpeed_run : physics_cur.MaxSpeed_walk) *(_onGround?physics_cur.ground_c_max:1.0f); phys_setup.min_vel_x = -fabs(_isRunning ? physics_cur.MaxSpeed_run : physics_cur.MaxSpeed_walk) *(_onGround?physics_cur.ground_c_max:1.0f); } if(keys.alt_run) { if(attack_enabled && !attack_pressed && !climbing) { attack_pressed=true; if(keys.up) attack(Attack_Up); else if(keys.down) attack(Attack_Down); else { attack(Attack_Forward); PGE_Audio::playSoundByRole(obj_sound_role::PlayerTail); animator.playOnce(MatrixAnimator::RacoonTail, _direction, 75, true, true, 1); } } } else { if(attack_pressed) attack_pressed=false; } //if if(!keys.up && !keys.down && !keys.left && !keys.right) { if(wasEntered) { wasEntered = false; wasEnteredTimeout=0; } } //Reset state if(wasEntered) { wasEnteredTimeout-=ticks; if(wasEnteredTimeout<0) { wasEnteredTimeout=0; wasEntered=false; } } if(keys.up) { if(climbableUp&&(jumpTime<=0)) { setDuck(false); climbing=true; floating_isworks=false;//!< Reset floating on climbing start } if(climbing) { if(posRect.center().y() >= climbableHeight) setSpeedY(-physics_cur.velocity_climb_y_up); } } if(keys.down) { if( climbableDown && (jumpTime<=0) ) { setDuck(false); climbing=true; floating_isworks=false;//!< Reset floating on climbing start } else { if((duck_allow & !ducking)&&( (animator.curAnimation()!=MatrixAnimator::RacoonTail) ) ) { setDuck(true); } } if(climbing) { setSpeedY(physics_cur.velocity_climb_y_down); } } else { if(ducking) setDuck(false); } if( (!keys.left) || (!keys.right) ) { bool turning=(((speedX()>0)&&(_direction<0))||((speedX()<0)&&(_direction>0))); float force = turning? physics_cur.decelerate_turn : (fabs(speedX())>physics_cur.MaxSpeed_walk)?physics_cur.run_force : physics_cur.walk_force; if(on_slippery_surface) force=force/physics_cur.slippery_c; else if((_onGround)&&(physics_cur.ground_c!=1.0f)) force=force*physics_cur.ground_c; if(keys.left) _direction=-1; if(keys.right) _direction=1; if(!ducking || !_onGround) { //If left key is pressed if(keys.right && collided_right.isEmpty()) { if(climbing) setSpeedX(physics_cur.velocity_climb_x); else applyAccel(force, 0); } //If right key is pressed if(keys.left && collided_left.isEmpty()) { if(climbing) setSpeedX(-physics_cur.velocity_climb_x); else applyAccel(-force, 0); } } } if( keys.alt_jump ) { //Temporary it is ability to fly up! if(!bumpDown && !bumpUp) { setSpeedY(-physics_cur.velocity_jump); } } if( keys.jump ) { if(!JumpPressed) { if(environment!=LVL_PhysEnv::Env_Water) { if(climbing || _onGround || (environment==LVL_PhysEnv::Env_Quicksand)) PGE_Audio::playSoundByRole(obj_sound_role::PlayerJump); } else PGE_Audio::playSoundByRole(obj_sound_role::PlayerWaterSwim); } if((environment==LVL_PhysEnv::Env_Water)||(environment==LVL_PhysEnv::Env_Quicksand)) { if(!JumpPressed) { if(environment==LVL_PhysEnv::Env_Water) { if(!ducking) animator.playOnce(MatrixAnimator::SwimUp, _direction, 75); } else if(environment==LVL_PhysEnv::Env_Quicksand) { if(!ducking) animator.playOnce(MatrixAnimator::JumpFloat, _direction, 64); } JumpPressed=true; jumpTime = physics_cur.jump_time; jumpVelocity=physics_cur.velocity_jump; floating_timer = floating_maxtime; setSpeedY(speedY()-jumpVelocity); } } else if(!JumpPressed) { JumpPressed=true; if(_onGround || climbing) { climbing=false; jumpTime=physics_cur.jump_time; jumpVelocity=physics_cur.velocity_jump; floating_timer = floating_maxtime; setSpeedY(-jumpVelocity-fabs(speedX()/physics_cur.velocity_jump_c)); } else if((floating_allow)&&(floating_timer>0)) { floating_isworks=true; //if true - do floating with sin, if false - do with cos. floating_start_type=(speedY()<0); setSpeedY(0); setGravityScale(0); } } else { if(jumpTime>0) { jumpTime -= ticks; setSpeedY(-jumpVelocity-fabs(speedX()/physics_cur.velocity_jump_c)); } if(floating_isworks) { floating_timer -= ticks; if(floating_start_type) setSpeedY( state_cur.floating_amplitude*(-cos(floating_timer/80.0)) ); else setSpeedY( state_cur.floating_amplitude*(cos(floating_timer/80.0)) ); if(floating_timer<=0) { floating_timer=0; floating_isworks=false; setGravityScale(climbing?0:physics_cur.gravity_scale); } } } } else { jumpTime=0; if(JumpPressed) { JumpPressed=false; if(floating_allow) { if(floating_isworks) { floating_timer=0; floating_isworks=false; setGravityScale(climbing?0:physics_cur.gravity_scale); } } } } refreshAnimation(); animator.tickAnimation(ticks); PGE_RectF sBox = section->sectionLimitBox(); //Return player to start position on fall down if( posY() > sBox.bottom()+_height ) { kill(DEAD_fall); } if(bumpDown) { bumpDown=false; jumpTime=0; setSpeedY(bumpVelocity); } else if(bumpUp) { bumpUp=false; if(keys.jump) { jumpTime=bumpJumpTime; jumpVelocity=bumpJumpVelocity; } setSpeedY( (keys.jump ? (-fabs(bumpJumpVelocity)-fabs(speedX()/physics_cur.velocity_jump_c)): -fabs(bumpJumpVelocity)) ); } //Connection of section opposite sides if(isExiting) // Allow walk offscreen if exiting { if((posX() < sBox.left()-_width-1 )||(posX() > sBox.right() + 1 )) { setGravityScale(0.0);//Prevent falling [we anyway exited from this level, isn't it?] setSpeedY(0.0); } if(keys.left||keys.right) { if((environment==LVL_PhysEnv::Env_Water)||(environment==LVL_PhysEnv::Env_Quicksand)) { keys.run=true; if(_exiting_swimTimer<0 && !keys.jump) keys.jump=true; else if(_exiting_swimTimer<0 && keys.jump) { keys.jump=false; _exiting_swimTimer=(environment==LVL_PhysEnv::Env_Quicksand)? 1 : 500; } _exiting_swimTimer-= ticks; } else keys.run=false; } } else if(section->isWarp()) { if(posX() < sBox.left()-_width-1 ) setPosX( sBox.right()+1 ); else if(posX() > sBox.right() + 1 ) setPosX( sBox.left()-_width-1 ); } else { if(section->ExitOffscreen()) { if(section->RightOnly()) { if( posX() < sBox.left()) { setPosX( sBox.left() ); setSpeedX(0.0); } } if((posX() < sBox.left()-_width-1 ) || (posX() > sBox.right() + 1 )) { setLocked(true); _no_render=true; LvlSceneP::s->setExiting(1000, LvlExit::EXIT_OffScreen); return; } } else { //Prevent moving of player away from screen if( posX() < sBox.left()) { setPosX(sBox.left()); setSpeedX(0.0); } else if( posX()+_width > sBox.right()) { setPosX(sBox.right()-_width); setSpeedX(0.0); } } } if(_stucked) { posRect.setX(posRect.x()-_direction*2); applyAccel(0, 0); } processWarpChecking(); if(_doSafeSwitchCharacter) setCharacter(characterID, stateID); try { lua_onLoop(); } catch (luabind::error& e) { LvlSceneP::s->getLuaEngine()->postLateShutdownError(e); } updateCamera(); }
int main() { int c, nbErreur = 0, accolade = 0, ligne = 0; enum {ETAT_DEBUT_LIGNE, ETAT_NORMAL, ETAT_COMMENTAIRE, ETAT_DEBUT_COMMENTAIRE, ETAT_GUILLEMET, ETAT_DIESE, ETAT_OPERATOR, ETAT_SIMPLE_QUOTE } etat = ETAT_DEBUT_LIGNE; /* plop plip ploup */ while ((c=getchar()) != EOF) { ligne++; switch (etat) { case ETAT_DEBUT_LIGNE: switch (c) { case ' ': /*cas d'un espace*/ break; case '\t': /*cas d'une tabulation*/ break; case '\n': /*cas d'un retour a la ligne*/ setCharacter(c); break; case ';' : /*cas d'un point virgule*/ indentText(); putchar(c); putchar('\n'); setCharacter(c); break; case '/' : /*cas d'un slash*/ setCharacter(c); break; case '#': setCharacter(c); putchar(c); etat = ETAT_DIESE; break; case '*' : /*cas d'un début de commentaire*/ if (previousCharacters[0] == '/') { putchar('\n'); indentText(); etat = ETAT_DEBUT_COMMENTAIRE; putchar(previousCharacters[0]); putchar(c); } setCharacter(c); break; case '{' : /*cas d'une acolade ouvrante*/ if (previousCharacters[0] != '\n' && previousCharacters[0] != ';' && previousCharacters[0] != '}') putchar('\n'); indentText(); putchar(c); putchar('\n'); indent++; accolade++; setCharacter(c); break; case '}' : /*cas d'une accolade fermante*/ if (previousCharacters[0] != '\n' && previousCharacters[0] != ';' && previousCharacters[0] != '}' ) putchar('\n'); indent--; indentText(); putchar(c); putchar('\n'); accolade--; setCharacter(c); break; case '\0': /*cas de fin de fichier*/ break; default: /* sinon */ indentText(); putchar(c); setCharacter(c); etat = ETAT_NORMAL; break; } break; case ETAT_NORMAL: switch (c) { case '\n': /*cas d'un retour a la ligne*/ putchar(c); etat = ETAT_DEBUT_LIGNE; setCharacter(c); break; case ';' : /*cas d'un point virgule*/ putchar(c); putchar('\n'); etat = ETAT_DEBUT_LIGNE; setCharacter(c); break; case '/' : /* cas d'un slash */ setCharacter(c); break; case '*' : /*cas d'un début de commentaire*/ if (previousCharacters[0] == '/') { if (previousCharacters[1] != '\n') putchar('\n'); indentText(); etat = ETAT_DEBUT_COMMENTAIRE; putchar(previousCharacters[0]); putchar(c); } setCharacter(c); break; case 'r': /* cas du for */ putchar(c); if ((previousCharacters[0] == 'o') && (previousCharacters[1] == 'f')) etat = ETAT_OPERATOR; setCharacter(c); break; case 'f': /* cas du if */ putchar(c); if (previousCharacters[0] == 'i') etat = ETAT_OPERATOR; setCharacter(c); break; case '\'' : /* cas d'un simple quote */ putchar(c); setCharacter(c); etat = ETAT_SIMPLE_QUOTE; break; case '"' : /* cas d'un guillemet ouvrant */ putchar(c); setCharacter(c); etat = ETAT_GUILLEMET; break; case '{' : /*cas d'une accolade ouvrante*/ if (previousCharacters[0] != '\n' && previousCharacters[0] != ';' && previousCharacters[0] != '}') putchar('\n'); indentText(); putchar(c); putchar('\n'); indent++; accolade++; etat = ETAT_DEBUT_LIGNE; setCharacter(c); break; case '}' : /*cas d'une accolade fermante*/ if (previousCharacters[0] != '\n' && previousCharacters[0] != ';' && previousCharacters[0] != '}') putchar('\n'); indent--; indentText(); putchar(c); putchar('\n'); accolade--; etat = ETAT_DEBUT_LIGNE; setCharacter(c); break; case '\0': /*cas de fin de fichier*/ break; default : /*sinon*/ putchar(c); setCharacter(c); break; } break; case ETAT_DEBUT_COMMENTAIRE : switch(c) { case ' ' : break; case '\t' : break; default : putchar(' '); putchar(c); setCharacter(c); etat = ETAT_COMMENTAIRE; break; } break; case ETAT_COMMENTAIRE : switch(c) { case '\n' : /* cas de retour a la ligne sans fin de commentaire*/ if (previousCharacters[1] == '*' && previousCharacters[0] == '/') { putchar(c); } else { if (previousCharacters[2] != ' ') putchar(' '); putchar('*'); putchar('/'); putchar('\n'); indentText(); putchar('/'); putchar('*'); fputs("commentaire non fini détecté à la ligne : "+ligne,stderr); nbErreur++; } setCharacter(c); etat = ETAT_DEBUT_COMMENTAIRE; break; case '/' : /* cas de fin de commentaire */ if (previousCharacters[0] == '*') { if (previousCharacters[1] != ' ') putchar(' '); etat = ETAT_DEBUT_LIGNE; putchar('/'); putchar('\n'); } else { putchar('/'); } setCharacter(c); break; case '\0': /*cas de fin de fichier*/ break; default : /* sinon */ setCharacter(c); putchar(c); break; } break; case ETAT_GUILLEMET : switch (c) { case '"' : setCharacter(c); putchar(c); etat = ETAT_NORMAL; break; default : /* sinon */ setCharacter(c); putchar(c); break; } break; case ETAT_SIMPLE_QUOTE : switch (c) { case '\'' : if (previousCharacters[0] == '\\' || ( previousCharacters[0] == '\\' && previousCharacters[1] == '\\' )) { putchar(c); etat = ETAT_SIMPLE_QUOTE; }else { putchar(c); etat = ETAT_NORMAL; } setCharacter(c); break; default : /* sinon */ setCharacter(c); putchar(c); break; } break; case ETAT_DIESE : switch (c) { case '\n' : setCharacter(c); putchar(c); etat = ETAT_DEBUT_LIGNE; break; default : /* sinon */ setCharacter(c); putchar(c); break; } break; case ETAT_OPERATOR : switch (c) { case ')' : setCharacter(c); putchar(c); etat = ETAT_NORMAL; break; default : /* sinon */ setCharacter(c); putchar(c); break; } break; } } if (accolade != 0) { if (accolade > 0) fputs("too much {" ,stderr); else fputs("too much }" ,stderr); exit(EXIT_FAILURE); } else if (nbErreur != 0) { printf("there are %d errors\n", nbErreur); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setWindowTitle("Browzi"); QMenu* fileMenu = menuBar()->addMenu(tr("&File")); fileMenu->addAction(tr("E&xit"), this, SLOT(close()), QKeySequence(Qt::ALT | Qt::Key_F4)); QMenu* viewMenu = menuBar()->addMenu(tr("&View")); viewMenu->addAction(tr("&Font..."), this, SLOT(showFontDialog())); QActionGroup* pinyinGroup = new QActionGroup(this); pa = new QAction("Accented Pinyin",this); pa->setCheckable(true); pinyinGroup->addAction(pa); pn = new QAction("Numbered Pinyin",this); pn->setCheckable(true); pinyinGroup->addAction(pn); connect(pinyinGroup, SIGNAL(triggered(QAction*)), this, SLOT(pinyinDisplayChanged(QAction*))); viewMenu->addSeparator(); viewMenu->addAction(pa); viewMenu->addAction(pn); QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(tr("Visit &Website"), this, SLOT(goToWebsite())); helpMenu->addAction(tr("&About Browzi"), this, SLOT(showAboutBox())); // Holds all the sub-widgets QWidget* mainPanel = new QWidget(this); // hzLayout has the tabs in the left, the character display in the right QHBoxLayout* hzLayout = new QHBoxLayout(mainPanel); // Set up the search tab tabWidget = new QTabWidget(mainPanel); // Add tabs to the widget SearchRadical* searchByRadical = new SearchRadical(mainPanel); tabWidget->addTab(searchByRadical, QString("Radical")); SearchStrokeCount* searchByStrokeCount = new SearchStrokeCount(); tabWidget->addTab(searchByStrokeCount, QString("Stroke Count")); SearchDraw* searchByDraw = new SearchDraw(tabWidget); tabWidget->addTab(searchByDraw, "Draw"); SearchPinyin* searchPinyin = new SearchPinyin(); tabWidget->addTab(searchPinyin, "Pinyin"); SearchEnglish* searchEnglish = new SearchEnglish(); tabWidget->addTab(searchEnglish, "English"); Clipboard* clipboard = new Clipboard(); tabWidget->addTab(clipboard, "Clipboard"); hzLayout->addWidget(tabWidget); hzLayout->setStretchFactor(tabWidget, 2); // vtLayout contains the character panel, plus a spacer and about button QVBoxLayout* vtLayout = new QVBoxLayout(); displayPanel = new CharacterDisplayPanel(); vtLayout->addWidget(displayPanel); QSpacerItem* verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); vtLayout->addItem(verticalSpacer); hzLayout->addLayout(vtLayout); hzLayout->setStretchFactor(vtLayout, 1); setCentralWidget(mainPanel); // Connect notifications connect(searchByRadical, SIGNAL(showCharacter(uint)), displayPanel, SLOT(setCharacter(uint))); connect(searchByStrokeCount, SIGNAL(showCharacter(uint)), displayPanel, SLOT(setCharacter(uint))); connect(searchByDraw, SIGNAL(showCharacter(uint)), displayPanel, SLOT(setCharacter(uint))); connect(searchPinyin, SIGNAL(showCharacter(uint)), displayPanel, SLOT(setCharacter(uint))); connect(searchEnglish, SIGNAL(showCharacter(uint)), displayPanel, SLOT(setCharacter(uint))); connect(clipboard, SIGNAL(showCharacter(uint)), displayPanel, SLOT(setCharacter(uint))); connect(this, SIGNAL(updateChineseFont(QFont)), searchByDraw, SLOT(setChineseFont(QFont))); connect(this, SIGNAL(updateChineseFont(QFont)), searchByRadical, SLOT(setChineseFont(QFont))); connect(this, SIGNAL(updateChineseFont(QFont)), searchByStrokeCount, SLOT(setChineseFont(QFont))); connect(this, SIGNAL(updateChineseFont(QFont)), searchPinyin, SLOT(setChineseFont(QFont))); connect(this, SIGNAL(updateChineseFont(QFont)), searchEnglish, SLOT(setChineseFont(QFont))); connect(this, SIGNAL(updateChineseFont(QFont)), clipboard, SLOT(setChineseFont(QFont))); connect(this, SIGNAL(updateChineseFont(QFont)), displayPanel, SLOT(setChineseFont(QFont))); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int))); QSettings s("Browzi", "Browzi"); setGeometry(QRect(s.value("pos", QPoint(200,100)).toPoint(), s.value("size",QSize(600,400)).toSize())); lastFont = QFont(s.value("font","unifont").toString(), 12); emit updateChineseFont(lastFont); PinyinConvertor::Mode m = PinyinConvertor::Mode(s.value("pinyin", 0).toInt()); if(m == PinyinConvertor::PINYIN_ACCENTED) { pa->setChecked(true); PinyinConvertor::setAccented(); } if(m == PinyinConvertor::PINYIN_NUMBERED) { pn->setChecked(true); PinyinConvertor::setNumbered(); } }
BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HMENU hMenu; HWND comboControl1; HWND comboControl2; HWND comboControl3; comboControl1=GetDlgItem(hwnd,IDC_COMBO1); comboControl2=GetDlgItem(hwnd,IDC_COMBO2); comboControl3=GetDlgItem(hwnd,IDC_COMBO3); BOOL status = FALSE; JABIA_Character * ptr = 0; // character address switch (message) { case WM_INITDIALOG: BringWindowToTop(hwnd); // add menu hMenu = LoadMenu(g_hModule, MAKEINTRESOURCE(IDR_MENU1)); SetMenu(hwnd,hMenu); // add icon HICON hIcon; hIcon = (HICON)LoadImage( g_hModule, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0); if(hIcon) { SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); } // add characters to drop down list for(unsigned long i = 0; i < jabia_characters.size(); i++) { SendMessage(comboControl1,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)jabia_characters.at(i)->merc_name)); char buf[255]; wsprintf(buf, "In init, Character at 0x%X", jabia_characters.at(i)); OutputDebugString(buf); } // select fist item in list SendMessage(comboControl1, CB_SETCURSEL, last_character_selected_index, 0); // add weapons slots to their combo box SendMessage(comboControl2,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)"1")); SendMessage(comboControl2,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)"2")); SendMessage(comboControl2,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)"3")); // select fist item in list SendMessage(comboControl2, CB_SETCURSEL, last_weaponslot_selected_index, 0); // add inventory slots to their combo box for(int i = 0; i < JABIA_CHARACTER_INV_SLOTS; i++) { char buf[5]; //wsprintf(buf, "%i", i); SendMessage(comboControl3,CB_ADDSTRING,0,reinterpret_cast<LPARAM>((LPCTSTR)buf)); } // select fist item in list SendMessage(comboControl3, CB_SETCURSEL, 0, 0); break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_COMBO1: switch(HIWORD(wParam)) { case CBN_CLOSEUP: // use combo box selected index to get a character out of the vector last_character_selected_index = SendMessage(comboControl1, CB_GETCURSEL, 0, 0); ptr = jabia_characters.at(last_character_selected_index); fillDialog(hwnd, ptr); break; } break; case IDC_COMBO2: switch(HIWORD(wParam)) { case CBN_CLOSEUP: // use combo box selected index to get weapon from inventory last_weaponslot_selected_index = SendMessage(comboControl2, CB_GETCURSEL, 0, 0); ptr = jabia_characters.at(last_character_selected_index); fillDialog(hwnd, ptr); break; } break; case IDC_COMBO3: switch(HIWORD(wParam)) { case CBN_CLOSEUP: // use combo box selected index to get weapon from inventory last_inventory_selected_index = SendMessage(comboControl3, CB_GETCURSEL, 0, 0); ptr = jabia_characters.at(last_character_selected_index); fillDialog(hwnd, ptr); break; } break; case IDSET: //char buf[50]; //wsprintf(buf, "Setting"); ptr = jabia_characters.at(last_character_selected_index); setCharacter(hwnd, ptr); break; case IDM_HEAL_CHARACTER: ptr = jabia_characters.at(last_character_selected_index); heal_character(ptr); fillDialog(hwnd, ptr); break; case IDM_KILL_CHARACTER: ptr = jabia_characters.at(last_character_selected_index); kill_character(ptr); fillDialog(hwnd, ptr); break; case IDM_STUN_CHARACTER: ptr = jabia_characters.at(last_character_selected_index); stun_character(ptr); fillDialog(hwnd, ptr); break; case IDM_EQUIPMENT1: ptr = jabia_characters.at(last_character_selected_index); give_equipment1(ptr); fillDialog(hwnd, ptr); break; case IDM_DUMP_CHARACTER: ptr = jabia_characters.at(last_character_selected_index); dump_current_character(hwnd, ptr); break; case IDM_DUMP_ALL: dump_all_characters(hwnd); break; case IDCANCEL: DestroyWindow(hwnd); PostQuitMessage(0); break; } break; default: return FALSE; } return FALSE; }