void DreamWebEngine::doSomeTalk() { while (true) { const uint8 *str = getPersonText(_character & 0x7F, _talkPos); if (*str == 0) { // endheartalk _pointerMode = 0; return; } createPanel(); showPanel(); showMan(); showExit(); convIcons(); printDirect(str, 164, 64, 144, false); loadSpeech('R', _realLocation, 'C', (64 * (_character & 0x7F)) + _talkPos); if (_speechLoaded) playChannel1(62); _pointerMode = 3; workToScreenM(); if (hangOnPQ()) return; _talkPos++; str = getPersonText(_character & 0x7F, _talkPos); if (*str == 0) { // endheartalk _pointerMode = 0; return; } if (*str != ':' && *str != 32) { createPanel(); showPanel(); showMan(); showExit(); convIcons(); printDirect(str, 48, 128, 144, false); loadSpeech('R', _realLocation, 'C', (64 * (_character & 0x7F)) + _talkPos); if (_speechLoaded) playChannel1(62); _pointerMode = 3; workToScreenM(); if (hangOnPQ()) return; } _talkPos++; } }
//--------------------------------------------------------------------- void Profiler::initialize() { // create a new overlay to hold our Profiler display mOverlay = OverlayManager::getSingleton().create("Profiler"); mOverlay->setZOrder(500); // this panel will be the main container for our profile bars mProfileGui = createContainer(); OverlayElement* element; // we create an initial pool of 50 profile bars for (uint i = 0; i < mMaxDisplayProfiles; ++i) { // this is for the profile name and the number of times it was called in a frame element = createTextArea("profileText" + StringConverter::toString(i), 90, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, 14, "", false); mProfileGui->addChild(element); mProfileBars.push_back(element); // this indicates the current frame time element = createPanel("currBar" + StringConverter::toString(i), 0, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, mBarIndent, "Core/ProfilerCurrent", false); mProfileGui->addChild(element); mProfileBars.push_back(element); // this indicates the minimum frame time element = createPanel("minBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerMin", false); mProfileGui->addChild(element); mProfileBars.push_back(element); // this indicates the maximum frame time element = createPanel("maxBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerMax", false); mProfileGui->addChild(element); mProfileBars.push_back(element); // this indicates the average frame time element = createPanel("avgBar" + StringConverter::toString(i), mBarLineWidth, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, "Core/ProfilerAvg", false); mProfileGui->addChild(element); mProfileBars.push_back(element); // this indicates the text of the frame time element = createTextArea("statText" + StringConverter::toString(i), 20, mBarHeight, mGuiBorderWidth + (mBarHeight + mBarSpacing) * i, 0, 14, "", false); mProfileGui->addChild(element); mProfileBars.push_back(element); } // throw everything all the GUI stuff into the overlay and display it mOverlay->add2D(mProfileGui); mOverlay->show(); }
void DreamWebEngine::inventory() { if (_vars._manDead == 1 || _vars._watchingTime != 0) { blank(); return; } commandOnlyCond(32, 239); if (_mouseButton == _oldButton) return; if (!(_mouseButton & 1)) // only on left mouse button return; _timeCount = 0; _pointerMode = 0; _inMapArea = 0; animPointer(); createPanel(); showPanel(); examIcon(); showMan(); showExit(); underTextLine(); _pickUp = 0; _invOpen = 2; openInv(); readMouse(); showPointer(); workToScreen(); delPointer(); _openedOb = 255; examineOb(false); }
void DreamWebEngine::redes() { if (_channel1Playing != 255 || _talkMode != 2) { blank(); return; } if (_commandType != 217) { _commandType = 217; commandOnly(50); } if (!(_mouseButton & 1)) return; delPointer(); createPanel(); showPanel(); showMan(); showExit(); convIcons(); startTalk(); readMouse(); showPointer(); workToScreen(); delPointer(); }
void DreamWebEngine::selectOpenOb() { uint8 slotSize, slotCount; getAnyAd(&slotSize, &slotCount); if (slotCount == 255) { // Can't open the object blank(); return; } if (_commandType != 224) { _commandType = 224; commandWithOb(38, _objectType, _command); } if (_mouseButton == _oldButton || !(_mouseButton & 1)) return; _openedOb = _command; _openedType = _objectType; createPanel(); showPanel(); showMan(); examIcon(); showExit(); openInv(); openOb(); underTextLine(); readMouse(); showPointer(); workToScreen(); delPointer(); }
VideoItem::VideoItem(QString fileName, QObject *parent) { this->setParent(parent); _fileName = fileName; //_videoData = new XMPMetadata(fileName); _emitShowTimeEnded = false; _player = new QMediaPlayer (this); _player->setVideoOutput(this); createPanel(); connect (_player, SIGNAL(positionChanged(qint64)), this, SLOT(on_positionChanged(qint64))); connect (_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(on_mediaStatusChanged(QMediaPlayer::MediaStatus))); connect (this, SIGNAL(nativeSizeChanged(QSizeF)), this, SLOT(on_nativeSizeChanged(QSizeF))); connect (_player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(on_stateChanged(QMediaPlayer::State))); connect (_player, SIGNAL(volumeChanged(int)), this, SLOT(on_volumeChanged(int))); }
void GraphHierarchiesEditor::doubleClicked(const QModelIndex& index) { if (!index.isValid() || index.internalPointer() == NULL) return; _contextGraph = index.data(tlp::TulipModel::GraphRole).value<tlp::Graph*>(); _model->setCurrentGraph(_contextGraph); createPanel(); _contextGraph = NULL; }
void ofApp::draw() { if (currentRenderType == MIDI_MANAGER) { ofBackground(155); //100, 75, 150); } else ofBackground(0); if (currentRenderType == NORMAL) { channels.draw(); } if (currentRenderType == NORMAL || currentRenderType == MIDI_MANAGER) { pianoKeys.draw(); } cam.begin(); // cout << cam.getLookAtDir() << endl; pm->draw(currentRenderType); cam.end(); ofSetColor(255); if (showPanel) { if (needsToRedrawPanel && currentPlate) { createPanel(currentPlate, false, currentRenderType == MIDI_MANAGER); cout << "redraw" << endl; needsToRedrawPanel = false; } panel.draw(); } if (connecting) { ofPushStyle(); ofSetColor(100, 255, 160); ofSetLineWidth(2); ofDrawLine(connectStart, connectEnd); ofPopStyle(); } if (currentRenderType == NOTE_SELECT) { pm->savePanel.draw(); } ofSetColor(255); ofDrawBitmapString(ofToString(currentRenderType), 10, ofGetHeight()- 10); tempPanel.draw(); // panel.draw(); // ofTranslate(mouseX, mouseY); // button.draw(); }
WorkspacePanel::WorkspacePanel(wxWindow* parent, wxWindowID id /* = wxID_ANY */, const wxPoint& pos /* = wxDefaultPosition */, const wxSize& size /* = wxDefaultSize */, long style /* = wxTAB_TRAVERSAL | wxNO_BORDER */, const wxString& name /* = wxT("Workspace Panel")) */) : mImageList(NULL), wxPanel(parent, id, pos, size, style, name) { createPanel(); Workspace::getSingletonPtr()->subscribe(Workspace::ProjectAdded, boost::bind(&WorkspacePanel::projectAdded, this, _1)); Workspace::getSingletonPtr()->subscribe(Workspace::ProjectRemoved, boost::bind(&WorkspacePanel::projectRemoved, this, _1)); }
Widget* initializeChooseWorldWindow(SDL_Surface* windowSurface) { Widget* window = createWindow(windowSurface); char stringBuffer[SELECT_WORLD_STRING_LENGTH]; char digitBuffer[2]; strcpy(stringBuffer, SELECT_WORLD_COOSE_TEXT); SDL_Rect panelRect = { 300, 150, 400, 600 }; Widget* panel = createPanel(windowSurface, panelRect, SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B)); addChild(window, panel); SDL_Rect labelRect = { 35, 20, 20, 20 }; Widget* label; if (currSelectionWindow == LOAD) { label = createLabel(labelRect, LOAD_GAME_TITLE, window->image, 0, 0, bitmapfont1, NULL); } else if (currSelectionWindow == EDIT) { label = createLabel(labelRect, EDIT_GAME_TITLE, window->image, 0, 0, bitmapfont1, NULL); } else { label = createLabel(labelRect, SAVE_GAME_TITLE, window->image, 0, 0, bitmapfont1, NULL); } addChild(panel, label); SDL_Rect buttonSelectRect = { 20, 60, 20, 20 }; SDL_Rect buttonDoneRect = { 20, 130, 20, 20 }; SDL_Rect buttonBackRect = { 20, 200, 20, 20 }; SDL_Rect buttonUpRect = { 186, 60, 20, 20 }; SDL_Rect buttonDownRect = { 186, 84, 20, 20 }; sprintf(digitBuffer, "%d", currWorld); strcat(stringBuffer, digitBuffer); Widget* buttonSelect = createButton(buttonSelectRect, stringBuffer, window->image, MARKED, "select_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 25, 10, BUTTON_SELECT_WORLD, bitmapfont1); addChild(panel, buttonSelect); Widget* buttonDone = createButton(buttonDoneRect, SELECT_WORLD_DONE_TEXT, window->image, REGULAR, "button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 25, 10, BUTTON_SELECT_WORLD_DONE, bitmapfont1); addChild(panel, buttonDone); Widget* buttonBack = createButton(buttonBackRect, SELECT_WORLD_BACK_TEXT, window->image, REGULAR, "button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SELECT_WORLD_BACK, bitmapfont1); addChild(panel, buttonBack); Widget* buttonUp = createButton(buttonUpRect, NULL, window->image, REGULAR, "up_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SELECT_WORLD_INCREASE, bitmapfont1); addChild(panel, buttonUp); Widget* buttonDown = createButton(buttonDownRect, NULL, window->image, REGULAR, "down_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SELECT_WORLD_DECREASE, bitmapfont1); addChild(panel, buttonDown); return window; }
void DreamWebEngine::talk() { _talkPos = 0; _inMapArea = 0; _character = _command; createPanel(); showPanel(); showMan(); showExit(); underTextLine(); convIcons(); startTalk(); _commandType = 255; readMouse(); showPointer(); workToScreen(); RectWithCallback<DreamWebEngine> talkList[] = { { 273,320,157,198,&DreamWebEngine::getBack1 }, { 240,290,2,44,&DreamWebEngine::moreTalk }, { 0,320,0,200,&DreamWebEngine::blank }, { 0xFFFF,0,0,0,0 } }; do { delPointer(); readMouse(); animPointer(); showPointer(); vSync(); dumpPointer(); dumpTextLine(); _getBack = 0; checkCoords(talkList); if (_quitRequested) break; } while (!_getBack); if (_talkPos >= 4) _personData->b7 |= 128; redrawMainScrn(); workToScreenM(); if (_speechLoaded) { cancelCh1(); _volumeDirection = -1; _volumeTo = 0; } }
void DreamWebEngine::examineInventory() { commandOnlyCond(32, 249); if (!(_mouseButton & 1)) return; createPanel(); showPanel(); showMan(); showExit(); examIcon(); _pickUp = 0; _invOpen = 2; openInv(); workToScreenM(); }
void DreamWebEngine::setPickup() { if (_objectType != kSetObjectType1 && _objectType != kSetObjectType3) { // Object types 1 and 3 are excluded, so the resulting object is a DynObject uint8 dummy; DynObject *object = (DynObject *)getAnyAd(&dummy, &dummy); if (object->mapad[0] == 4) { blank(); return; } } else { blank(); return; } if (_commandType != 209) { _commandType = 209; commandWithOb(33, _objectType, _command); } if (_mouseButton != 1 || _mouseButton == _oldButton) return; createPanel(); showPanel(); showMan(); showExit(); examIcon(); _pickUp = 1; _invOpen = 2; if (_objectType != kExObjectType) { assert(_objectType == kFreeObjectType); _openedOb = 255; _itemFrame = transferToEx(_command); _objectType = kExObjectType; DynObject *object = getExAd(_itemFrame); object->mapad[0] = 20; object->mapad[1] = 255; } else { _itemFrame = _command; _openedOb = 255; } openInv(); workToScreenM(); }
GenericSlider::GenericSlider(wxWindow *window,wxString label,const wxPoint& pos,const wxSize& size,bool orientation) : wxPanel( window, wxID_ANY, pos, size) { title = label; limited = false; scroll=false; value=0; ticks=10; parent = window; currentMax=max=100; currentMin=min=0; createPanel(orientation); }
HudRadarDisplay::HudRadarDisplay(hud_part_design_t& a_hud_part_design) : HudPart(a_hud_part_design) { // start off with the radar active status read from the radar computer Enabled = Game::Hud->radar->getActive(); Game::Hud->Controller->ControlBlock.radar = Enabled; Game::Hud->radar->setRadarRange(radar_ranges[RangeIndex]); GreenMaterial = GameHud::createOverlayMaterial(dot_green_name); RedMaterial = GameHud::createOverlayMaterial(dot_red_name); for (size_t i = 0; i < num_of_initial_dots; ++i) { string id = string("radar_dot_") + intoString(i); DotElements.push_back(createPanel(id, dot_green_name, 0, 0, 8, 8, Container)); DotElements.back()->hide(); } }
Widget* initializeChooseSkillWindow(SDL_Surface* windowSurface) { Widget* window = createWindow(windowSurface); char buffer[3]; SDL_Rect panelRect = { 300, 150, 400, 600 }; Widget* panel = createPanel(windowSurface, panelRect, SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B)); addChild(window, panel); SDL_Rect labelRect = { 35, 20, 20, 20 }; Widget* label; if (currAnimal == CAT) { label = createLabel(labelRect, CHOOSE_CAT_SKILL_TITLE, window->image, 0, 0, bitmapfont1, NULL); } else { label = createLabel(labelRect, CHOOSE_MOUSE_SKILL_TITLE, window->image, 0, 0, bitmapfont1, NULL); } addChild(panel, label); SDL_Rect buttonSelectRect = { 20, 60, 20, 20 }; SDL_Rect buttonDoneRect = { 20, 130, 20, 20 }; SDL_Rect buttonBackRect = { 20, 200, 20, 20 }; SDL_Rect buttonUpRect = { 186, 60, 20, 20 }; SDL_Rect buttonDownRect = { 186, 84, 20, 20 }; sprintf(buffer, "%d", currSkill); Widget* buttonSelect = createButton(buttonSelectRect, buffer, window->image, MARKED, "select_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 25, 10, BUTTON_SKILL_LEVEL, bitmapfont1); addChild(panel, buttonSelect); Widget* buttonDone = createButton(buttonDoneRect, SKILL_DONE_TEXT, window->image, REGULAR, "button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 25, 10, BUTTON_SKILL_DONE, bitmapfont1); addChild(panel, buttonDone); Widget* buttonBack = createButton(buttonBackRect, SKILL_BACK_TEXT, window->image, REGULAR, "button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SKILL_BACK, bitmapfont1); addChild(panel, buttonBack); Widget* buttonUp = createButton(buttonUpRect, NULL, window->image, REGULAR, "up_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SKILL_INCREASE, bitmapfont1); addChild(panel, buttonUp); Widget* buttonDown = createButton(buttonDownRect, NULL, window->image, REGULAR, "down_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SKILL_DECREASE, bitmapfont1); addChild(panel, buttonDown); return window; }
void DreamWebEngine::examineOb(bool examineAgain) { _pointerMode = 0; _timeCount = 0; while (true) { if (examineAgain) { _inMapArea = 0; _examAgain = 0; _openedOb = 255; _openedType = 255; _invOpen = 0; _objectType = _commandType; _itemFrame = 0; _pointerFrame = 0; createPanel(); showPanel(); showMan(); showExit(); obIcons(); obPicture(); describeOb(); underTextLine(); _commandType = 255; readMouse(); showPointer(); workToScreen(); delPointer(); examineAgain = false; } readMouse(); showPointer(); waitForVSync(); dumpPointer(); dumpTextLine(); delPointer(); _getBack = 0; switch (_invOpen) { case 0: { RectWithCallback examList[] = { { 273,320,157,198,&DreamWebEngine::getBackFromOb }, { 260,300,0,44,&DreamWebEngine::useObject }, { 210,254,0,44,&DreamWebEngine::selectOpenOb }, { 144,176,64,96,&DreamWebEngine::setPickup }, { 0,50,50,200,&DreamWebEngine::examineInventory }, { 0,320,0,200,&DreamWebEngine::blank }, { 0xFFFF,0,0,0,0 } }; checkCoords(examList); break; } case 1: { // Note: This table contains the non-constant _openChangeSize! RectWithCallback invList1[] = { { 273,320,157,198,&DreamWebEngine::getBackFromOb }, { 255,294,0,24,&DreamWebEngine::dropObject }, { kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamWebEngine::incRyanPage }, { kInventx,_openChangeSize,kInventy+100,kInventy+100+kItempicsize,&DreamWebEngine::useOpened }, { kInventx,kInventx+(5*kItempicsize),kInventy,kInventy+(2*kItempicsize),&DreamWebEngine::inToInv }, { 0,320,0,200,&DreamWebEngine::blank }, { 0xFFFF,0,0,0,0 } }; checkCoords(invList1); break; } default: { RectWithCallback withList1[] = { { 273,320,157,198,&DreamWebEngine::getBackFromOb }, { kInventx+167,kInventx+167+(18*3),kInventy-18,kInventy-2,&DreamWebEngine::incRyanPage }, { kInventx,kInventx+(5*kItempicsize), kInventy,kInventy+(2*kItempicsize),&DreamWebEngine::selectOb }, { 0,320,0,200,&DreamWebEngine::blank }, { 0xFFFF,0,0,0,0 } }; checkCoords(withList1); break; } } if (_quitRequested) break; if (_examAgain != 0) examineAgain = true; else if (_getBack != 0) break; } _pickUp = 0; if (_vars._watchingTime != 0 || _newLocation == 255) { // isWatching makeMainScreen(); } _invOpen = 0; _openedOb = 255; }
void TuiManager::parseControl(Node* container,xml_node<char> *item) { int tag = atof(item->first_attribute("tag")->value()); int x = atof(item->first_attribute("x")->value()); int y = atof(item->first_attribute("y")->value()); int w = atoi(item->first_attribute("width")->value()); int h = atoi(item->first_attribute("height")->value()); int rotation = atof(item->first_attribute("rotation")->value()); if(strcmp(item->first_attribute("type")->value(), kTuiContainerPanel) == 0){//panel CWidgetWindow* pPanel = createPanel(tag,x,y,w,h,rotation); container->addChild(pPanel); //recursive for( xml_node<char> *iitem = item->first_node( kTuiNodeControl );iitem != NULL; iitem = iitem->next_sibling()){ parseControl(pPanel,iitem); } }else if (strcmp(item->first_attribute("type")->value(), kTuiControlCell) == 0){//cell //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(container, iitem); } }else if(strcmp(item->first_attribute("type")->value(),kTuiControlImage) == 0){//image const char* file = item->first_attribute("image")->value(); float scaleX = atof(item->first_attribute("scaleX")->value()); float scaleY = atof(item->first_attribute("scaleY")->value()); CImageView *pImg = createImage(tag, file, scaleX, scaleY, x, y, rotation); container->addChild(pImg); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlImage9) == 0){//image9 const char* file = item->first_attribute("image")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); float up = atof(item->first_attribute("up")->value()); float down = atof(item->first_attribute("down")->value()); float left = atof(item->first_attribute("left")->value()); float right = atof(item->first_attribute("right")->value()); CImageViewScale9 *pImg = createImage9(tag,file,x,y,w,h,up,down,left,right,rotation); container->addChild(pImg); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlButton) == 0){//button const char* normal = item->first_attribute("normal")->value(); const char* select = item->first_attribute("select")->value(); const char* disable = item->first_attribute("disable")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); CButton *pBtn = createBtn(tag,normal,select,disable,x,y,w,h,rotation); container->addChild(pBtn); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlToggleView) == 0){//toggleView const char* normal = item->first_attribute("normal")->value(); const char* select = item->first_attribute("select")->value(); const char* disable = item->first_attribute("disable")->value(); float exclusion = atof(item->first_attribute("exclusion")->value()); CToggleView* toggle = createToggleView(tag,exclusion,normal,select,disable,x,y,rotation); container->addChild(toggle); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlSlider) == 0){//slider const char* bg = item->first_attribute("bg")->value(); const char* progress = item->first_attribute("progress")->value(); const char* thumb = item->first_attribute("thumb")->value(); CSlider *pSlider = createSlider(tag,bg,progress,thumb,x,y,rotation); container->addChild(pSlider); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlProgress) == 0){//progress const char* bg = item->first_attribute("bg")->value(); const char* progress = item->first_attribute("progress")->value(); CProgressBar *pProgress = createProgress(tag,bg,progress,x,y,rotation); container->addChild(pProgress); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlLabel) == 0){//label float size = atof(item->first_attribute("textSize")->value()); int alignment = atoi(item->first_attribute("alignment")->value()); const char* text = item->first_attribute("text")->value(); const char* font = item->first_attribute("textFont")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int r = atoi(item->first_attribute("red")->value()); int g = atoi(item->first_attribute("green")->value()); int b = atoi(item->first_attribute("blue")->value()); int r2 = atoi(item->first_attribute("strokeRed")->value()); int g2 = atoi(item->first_attribute("strokeGreen")->value()); int b2 = atoi(item->first_attribute("strokeBlue")->value()); int strokeSize = atoi(item->first_attribute("strokeSize")->value()); int shadowDistance = atoi(item->first_attribute("shadowDistance")->value()); int shadowBlur = atoi(item->first_attribute("shadowBlur")->value()); CLabel *pLabel = createLabel(tag, text, font, alignment, size, r, g, b, x, y, w, h, r2,g2,b2,strokeSize,shadowDistance,shadowBlur,rotation); container->addChild(pLabel); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlLabelAtlas) == 0){//labelAtlas const char* imgPath = item->first_attribute("image")->value(); float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); CLabelAtlas *pLabAtlas = createLabelAtlas(tag,imgPath,x,y,w,h,rotation); container->addChild(pLabAtlas); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlArmature) == 0){//armature const char* xml = item->first_attribute("xml")->value(); const char* png = item->first_attribute("png")->value(); const char* plist = item->first_attribute("plist")->value(); const char* name = item->first_attribute("name")->value(); Armature *pArmature = createArmature(tag,name,png,plist,xml,x,y,rotation); container->addChild(pArmature); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlAnim) == 0){//animation const char* png = item->first_attribute("png")->value(); const char* plist = item->first_attribute("plist")->value(); const char* name = item->first_attribute("name")->value(); Sprite *pSprite = createAnim(tag,name,png,plist,x,y,rotation); container->addChild(pSprite); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlControl) == 0){//controlView const char* baseboard = item->first_attribute("baseboard")->value(); const char* joystick = item->first_attribute("joystick")->value(); CControlView *pControl = createControl(tag,baseboard,joystick,x,y,rotation); container->addChild(pControl); }else if (strcmp(item->first_attribute("type")->value(), kTuiContainerScroll) == 0){//scrollView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int direction = atof(item->first_attribute("direction")->value()); int innerWidth = atoi(item->first_attribute("innerWidth")->value()); int innerHeight = atoi(item->first_attribute("innerHeight")->value()); CScrollView *pView = createScrollView(tag, direction, innerWidth, innerHeight, x, y, w, h, rotation); container->addChild(pView); //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(pView->getContainer(), iitem); } }else if (strcmp(item->first_attribute("type")->value(), kTuiContainerLayout) == 0){//layout float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); CLayout *pLayout = createLayout(tag, x, y, w, h, rotation); container->addChild(pLayout); //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(pLayout, iitem); } Vector<Node*> vet = pLayout->getChildren(); for (Node *pChild : vet){//Offset coordinates Because CLayout zero point in the lower left corner pChild->setPosition(pChild->getPosition() + Point(w / 2, h / 2)); } }else if(strcmp(item->first_attribute("type")->value(),kTuiControlListView) == 0){//listView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); const char* img = item->first_attribute("image")->value(); float num = atof(item->first_attribute("num")->value()); CListView* pList = createListView(tag,img,x,y,w,h,rotation); container->addChild(pList); for(int i=0; i<num;i++){//add item xml_node<char> *iitem = item->first_node( kTuiNodeControl ); w = atof(iitem->first_attribute("width")->value()); h = atof(iitem->first_attribute("height")->value()); CLayout *pLayout = createLayout(i,0,0,w,h,rotation); for( xml_node<char> *iiitem = iitem->first_node( kTuiNodeControl );iiitem!=NULL; iiitem = iiitem->next_sibling()){ parseControl(pLayout,iiitem); } Vector<Node*> vet = pLayout->getChildren(); for(Node *pChild : vet){//Offset coordinates Because CLayout zero point in the lower left corner if(pChild->getTag() > 0) pChild->setPosition(pChild->getPosition()+Point(w/2,h/2)); } pList->insertNodeAtLast(pLayout); } pList->reloadData(); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlPageView) == 0){//pageView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); float num = atoi(item->first_attribute("num")->value()); int dir = atoi(item->first_attribute("direction")->value()); const char* img = item->first_attribute("image")->value(); CPageView *pPageView = createPageView(tag, img, dir, num, x, y, w, h, rotation); container->addChild(pPageView); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlCheckBox) == 0){//checkBox const char* normal1 = item->first_attribute("normal1")->value(); const char* normal2 = item->first_attribute("normal2")->value(); const char* select1 = item->first_attribute("select1")->value(); const char* select2 = item->first_attribute("select2")->value(); const char* disable1 = item->first_attribute("disable1")->value(); const char* disable2 = item->first_attribute("disable2")->value(); CCheckBox *pCheckBox = createCheckBox(tag,normal1,normal2,select1,select2,disable1,disable2,x,y,rotation); container->addChild(pCheckBox); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlArmatureBtn) == 0){//ArmatureBtn const char* png = item->first_attribute("png")->value(); const char* plist = item->first_attribute("plist")->value(); const char* name = item->first_attribute("name")->value(); const char* xml = item->first_attribute("xml")->value(); ArmatureBtn *pArmBtn = createArmatureBtn(tag,name,png,plist,xml,x,y,rotation); container->addChild(pArmBtn); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlNumbericStepper) == 0){//NumbericStepper const char* lnormal = item->first_attribute("lnormal")->value(); const char* rnormal = item->first_attribute("rnormal")->value(); const char* lselect = item->first_attribute("lselect")->value(); const char* rselect = item->first_attribute("rselect")->value(); const char* ldisable = item->first_attribute("ldisable")->value(); const char* rdisable = item->first_attribute("rdisable")->value(); const char* stepBg = item->first_attribute("stepBg")->value(); NumericStepper *pNumStep = createNumStep(tag,lnormal,lselect,ldisable,rnormal,rselect,rdisable,stepBg,x,y,rotation); container->addChild(pNumStep); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlPaticle) == 0){//Paticle const char* plist = item->first_attribute("plist")->value(); ParticleSystem *pPartical = createParticle(tag,plist,x,y); container->addChild(pPartical); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlTable) == 0){//TableView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); float num = atoi(item->first_attribute("num")->value()); int dir = atoi(item->first_attribute("direction")->value()); int cellWidth = atoi(item->first_attribute("cellWidth")->value()); int cellHeight = atoi(item->first_attribute("cellHeight")->value()); const char* img = item->first_attribute("image")->value(); CTableView *pView = createTableView(tag, img, dir, num, cellWidth, cellHeight, x, y, w, h, rotation); container->addChild(pView); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlGridView) == 0){//GridView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int cellWidth = atoi(item->first_attribute("cellWidth")->value()); int cellHeight = atoi(item->first_attribute("cellHeight")->value()); int column = atoi(item->first_attribute("column")->value()); int num = atoi(item->first_attribute("num")->value()); const char* img = item->first_attribute("image")->value(); CGridView *pView = createGridView(tag, img, column, num, cellWidth, cellHeight, x, y, w, h, rotation); container->addChild(pView); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlGridPageView) == 0){//GridPageView float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); int cellWidth = atoi(item->first_attribute("cellWidth")->value()); int cellHeight = atoi(item->first_attribute("cellHeight")->value()); int column = atoi(item->first_attribute("column")->value()); int row = atoi(item->first_attribute("row")->value()); int num = atoi(item->first_attribute("num")->value()); int dir = atoi(item->first_attribute("direction")->value()); const char* img = item->first_attribute("image")->value(); CGridPageView *pView = createGridPageView(tag, img, dir, column, row, num, cellWidth, cellHeight, x, y, w, h, rotation); container->addChild(pView); }else if(strcmp(item->first_attribute("type")->value(),kTuiControlEditBox) == 0){//EditBox float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); const char* img = item->first_attribute("image")->value(); int inputMode = atoi(item->first_attribute("inputMode")->value()); int inputFlag = atoi(item->first_attribute("inputFlag")->value()); EditBox *pEdit = createEditBox(tag, img, inputMode, inputFlag, x, y, w, h, rotation); container->addChild(pEdit); }else if (strcmp(item->first_attribute("type")->value(), kTuiControlMovieView) == 0){//MovieView const char* png = item->first_attribute("png")->value(); const char* plist = item->first_attribute("plist")->value(); const char* json = item->first_attribute("json")->value(); MovieView *pMovieView = createMovieView(tag, json, plist, png, x, y, rotation); container->addChild(pMovieView); }else if (strcmp(item->first_attribute("type")->value(), kTuiContainerCircleMenu) == 0){//CircleMenu float w = atof(item->first_attribute("width")->value()); float h = atof(item->first_attribute("height")->value()); CircleMenu *pMenu = createCircleMenu(tag, x, y, w, h, rotation); container->addChild(pMenu); //recursive for (xml_node<char> *iitem = item->first_node(kTuiNodeControl); iitem != NULL; iitem = iitem->next_sibling()){ parseControl(pMenu, iitem); } pMenu->reloadData(); } }
WorkPanel* Document::workPanel() { if(!panel) createPanel(); return panel; }
void HudRadarDisplay::update(Real a_dt) { if (Enabled != Game::Hud->radar->getActive()) { Enabled != Enabled; if (!Enabled) { for (size_t i = 0, for_size = DotElements.size(); i < for_size; ++i) { DotElements[i]->hide(); } } } if(!Enabled) { return; } // radar radius change if (take(Game::Hud->Controller->ControlBlock.radar_zoom_in)) { // see smaller area if (RangeIndex > 0) { --RangeIndex; } // adjust radar sphere Game::Hud->radar->setRadarRange(radar_ranges[RangeIndex]); } else if (take(Game::Hud->Controller->ControlBlock.radar_zoom_out)) { // see larger area if (++RangeIndex == num_of_radar_ranges) { --RangeIndex; } // adjust radar sphere Game::Hud->radar->setRadarRange(radar_ranges[RangeIndex]); } // how many dots on the screen? vector<radar::CorpusDot>& dots = Game::Hud->radar->getDots(); size_t num_of_dots = dots.size(); // grow number of dots if needed if (DotElements.size() < num_of_dots) { for (size_t i = 0, for_size = num_of_dots - DotElements.size(); i < for_size; ++i) { string id = string("radar_dot_") + intoString(DotElements.size()); DotElements.push_back(createPanel(id, dot_green_name, 0, 0, 8, 8, Container)); DotElements.back()->hide(); } } Real radar_angle = (Game::Camera->getOrientation().getYaw()).valueRadians(); Real x0 = Game::Hud->PlayerUnit->getX(); Real y0 = Game::Hud->PlayerUnit->getZ(); Real range_scale = size.first / Game::Hud->radar->getRadarRange(); for (size_t i = 0, for_size = DotElements.size(); i < for_size; ++i) { if (i < num_of_dots && dots[i].detected) { Real dot_size = max(dots[i].size * range_scale, Real(8)); DotElements[i]->setDimensions(dot_size, dot_size); Real x = (dots[i].position.x - x0) * range_scale; Real y = (dots[i].position.z - y0) * range_scale; x = (cos(radar_angle) * x - sin(radar_angle) * y) * 0.5 + (size.first - dot_size) * 0.5; y = (sin(radar_angle) * x + cos(radar_angle) * y) * 0.5 + (size.first - dot_size) * 0.5; DotElements[i]->setPosition(x, y); DotElements[i]->show(); } else { DotElements[i]->hide(); } } }
int main(int argc, char **argv) { // OSG init osgInit(argc,argv); { // Set up Window WindowEventProducerRecPtr TutorialWindow = createNativeWindow(); TutorialWindow->initWindow(); // Create the SimpleSceneManager helper SimpleSceneManager sceneManager; TutorialWindow->setDisplayCallback(boost::bind(display, &sceneManager)); TutorialWindow->setReshapeCallback(boost::bind(reshape, _1, &sceneManager)); // Tell the Manager what to manage sceneManager.setWindow(TutorialWindow); TutorialWindow->connectKeyTyped(boost::bind(keyPressed, _1)); // Make Torus Node (creates Torus in background of scene) NodeRecPtr TorusGeometryNode = makeTorus(.5, 2, 16, 16); // Make Main Scene Node and add the Torus NodeRecPtr scene = Node::create(); scene->setCore(Group::create()); scene->addChild(TorusGeometryNode); // Create the Graphics GraphicsRecPtr TutorialGraphics = Graphics2D::create(); // Initialize the LookAndFeelManager to enable default settings LookAndFeelManager::the()->getLookAndFeel()->init(); /****************************************************** Create a RotatedComponent. -setAngle(Angle, in radians): Determine the angle the Component initially is rotated. -setInternalComponent(Component): Determine what Component will be rotated. -setResizePolicy(RotatedComponent::ENUM): Takes NO_RESIZING, RESIZE_TO_MIN, or RESIZE_TO_MAX arguments. ******************************************************/ RotatedComponentRecPtr TheRotatedComponent = RotatedComponent::create(); // Define PI Real32 PI(3.14159); TheRotatedComponent->setAngle(PI/4); ComponentRecPtr InnerPanel = createPanel(); TheRotatedComponent->setInternalComponent(InnerPanel); TheRotatedComponent->setResizePolicy(RotatedComponent::RESIZE_TO_MIN); /****************************************************** Create a ToggleButton which can be used to start and stop the Button from rotating. Note: due to the way FlowLayout works you will notice that this ToggleButton will move as well. In cases where a Rotating Component is used, an alternate Layout may be preferred to prevent other Components from moving as well. This is intentionally left this way to illustrate why this might be the case. A SplitPanel with fixed divider for example would prevent the ToggleButton from moving, while still allowing the Panel to move freely. ******************************************************/ ToggleButtonRecPtr RotateControlButton = ToggleButton::create(); RotateControlButton->setText("Start Rotating"); RotateControlButton->setPreferredSize(Vec2f(100.0f, 29.0f)); RotateControlButton->connectButtonSelected(boost::bind(handleButtonSelected, _1, TutorialWindow.get(), TheRotatedComponent.get())); RotateControlButton->connectButtonDeselected(boost::bind(handleButtonDeselected, _1, TutorialWindow.get(), TheRotatedComponent.get())); // Create The Main InternalWindow // Create Background to be used with the Main InternalWindow ColorLayerRecPtr MainInternalWindowBackground = ColorLayer::create(); MainInternalWindowBackground->setColor(Color4f(1.0,1.0,1.0,0.5)); LayoutRecPtr MainInternalWindowLayout = FlowLayout::create(); InternalWindowRecPtr MainInternalWindow = InternalWindow::create(); MainInternalWindow->pushToChildren(TheRotatedComponent); MainInternalWindow->pushToChildren(RotateControlButton); MainInternalWindow->setLayout(MainInternalWindowLayout); MainInternalWindow->setBackgrounds(MainInternalWindowBackground); MainInternalWindow->setAlignmentInDrawingSurface(Vec2f(0.5f,0.5f)); MainInternalWindow->setScalingInDrawingSurface(Vec2f(0.8f,0.8f)); MainInternalWindow->setDrawTitlebar(false); MainInternalWindow->setResizable(false); // Create the Drawing Surface UIDrawingSurfaceRecPtr TutorialDrawingSurface = UIDrawingSurface::create(); TutorialDrawingSurface->setGraphics(TutorialGraphics); TutorialDrawingSurface->setEventProducer(TutorialWindow); TutorialDrawingSurface->openWindow(MainInternalWindow); // Create the UI Foreground Object UIForegroundRecPtr TutorialUIForeground = UIForeground::create(); TutorialUIForeground->setDrawingSurface(TutorialDrawingSurface); // Tell the Manager what to manage sceneManager.setRoot(scene); // Add the UI Foreground Object to the Scene ViewportRecPtr TutorialViewport = sceneManager.getWindow()->getPort(0); TutorialViewport->addForeground(TutorialUIForeground); //Create the Documentation Foreground and add it to the viewport SimpleScreenDoc TheSimpleScreenDoc(&sceneManager, TutorialWindow); // Show the whole Scene sceneManager.showAll(); //Open Window Vec2f WinSize(TutorialWindow->getDesktopSize() * 0.85f); Pnt2f WinPos((TutorialWindow->getDesktopSize() - WinSize) *0.5); TutorialWindow->openWindow(WinPos, WinSize, "30RotatedComponent"); //Enter main Loop TutorialWindow->mainLoop(); } osgExit(); return 0; }
/** This function builds the game window, the chess game area and the side panel, and attaches * all the required logic and gui components to each other. When this method is done we can start processing events * to get the game going. */ GuiWindow* createGameWindow(char board[BOARD_SIZE][BOARD_SIZE], bool isUserBlack) { // Z indices under window short gameAreaPanelZIndex = 1; short sidePanelZIndex = 2; // Z indices under wooden panel short sidePanelImgZIndex = 0; short saveButtonZIndex = 1; short menuButtonZIndex = 2; short quitButtonZIndex = 3; GuiColorRGB bgcolor = WHITE; GuiWindow* gameWindow = createWindow(WIN_W, WIN_H, GAME_WINDOW_TITLE, bgcolor); if ((NULL == gameWindow) || g_guiError) return NULL; // Clean on errors // Set a custom destructor for the window gameWindow->generalProperties.destroy = destroyGameWindow; // Side panel creation Rectangle sidePanelBounds = { 0, 0, WOODPANEL_W, WOODPANEL_H }; sidePanelBounds.x = BOARD_W; // Panel is to the right of the board GuiPanel* sidePanel = createPanel(gameWindow->generalProperties.wrapper, sidePanelBounds, sidePanelZIndex, GREEN); if ((NULL == sidePanel) || g_guiError) { // Clean on errors destroyWindow(gameWindow); return NULL; } sidePanelBounds.x = 0; // Image is 0 relative to the panel GuiImage* sidePanelImg = createImage(sidePanel->generalProperties.wrapper, sidePanelBounds, sidePanelImgZIndex, SIDE_PANEL_IMG, GREEN); if ((NULL == sidePanelImg) || g_guiError) { // Clean on errors destroyWindow(gameWindow); return NULL; } Rectangle btnBounds = { ((WOODPANEL_W - (BUTTON_W / 2)) / 2), 0, BUTTON_W, BUTTON_H }; btnBounds.y = BESTMOVE_BUTTON_OFFSET_Y; GuiButton* bestMoveBtn = createButton(sidePanel->generalProperties.wrapper, btnBounds, saveButtonZIndex, BUTTON_BESTMOVE_IMG, BROWN, onBestMoveClick); if ((NULL == bestMoveBtn) || g_guiError) { // Clean on errors destroyWindow(gameWindow); return NULL; } btnBounds.y = SAVE_BUTTON_OFFSET_Y; GuiButton* saveBtn = createButton(sidePanel->generalProperties.wrapper, btnBounds, saveButtonZIndex, BUTTON_SAVE_IMG, BROWN, onSaveClick); if ((NULL == saveBtn) || g_guiError) { // Clean on errors destroyWindow(gameWindow); return NULL; } btnBounds.y = MENU_BUTTON_OFFSET_Y; GuiButton* mainMenuBtn = createButton(sidePanel->generalProperties.wrapper, btnBounds, menuButtonZIndex, BUTTON_MENU_IMG, BROWN, onMainMenuClick); if ((NULL == mainMenuBtn) || g_guiError) { // Clean on errors destroyWindow(gameWindow); return NULL; } btnBounds.y = QUIT_BUTTON_OFFSET_Y; GuiButton* quitBtn = createButton(sidePanel->generalProperties.wrapper, btnBounds, quitButtonZIndex, BUTTON_QUIT_IMG, BROWN, onQuit); if ((NULL == quitBtn) || g_guiError) { // Clean on errors destroyWindow(gameWindow); return NULL; } Rectangle gameAreaBounds = { 0, 0, BOARD_W, BOARD_H }; GuiPanel* gameAreaPanel = createPanel(gameWindow->generalProperties.wrapper, gameAreaBounds, gameAreaPanelZIndex, GRAY); if ((NULL == gameAreaPanel) || g_guiError) { destroyWindow(gameWindow); return NULL; } // Create the game window extent GameWindowExtent* windowExtent = createGameWindowExtent(gameWindow, gameAreaPanel, bestMoveBtn, board); if (NULL == windowExtent) { gameWindow->generalProperties.destroy(gameWindow); return NULL; } gameWindow->generalProperties.extent = windowExtent; GameControl* gameControl = windowExtent->gameControl; refreshBoard(gameControl); if (g_memError) { // Avoid errors gameWindow->generalProperties.destroy(gameWindow); return NULL; } saveBtn->generalProperties.extent = gameControl; // Save a reference to the game control / window in the button extents. // This makes the game control available on events. bestMoveBtn->generalProperties.extent = gameControl; mainMenuBtn->generalProperties.extent = gameWindow; quitBtn->generalProperties.extent = gameWindow; gameWindow->onShow = onGameWindowShow; // Set the onShow event, so when the window is drawn we can start playing return gameWindow; }