void Splitter::create(const Seed& cs) { pos = cs.pos; horizontal = cs.horizontal; BaseType::create(cs); theme.load(VSCLASS_WINDOW, this); onPainting([this](PaintCanvas& canvas) { handlePainting(canvas); }); onLeftMouseDown([this](const MouseEvent& mouseEvent) { return handleLButtonDown(mouseEvent); }); onMouseMove([this](const MouseEvent& mouseEvent) { return handleMouseMove(mouseEvent); }); onLeftMouseUp([this](const MouseEvent&) { return handleLButtonUp(); }); auto tip = WidgetCreator<ToolTip>::create(this, ToolTip::Seed()); tip->setText(Texts::get(Texts::resize)); onDestroy([tip] { tip->close(); }); }
void EditorToolBar::update(float deltaTime) { ASSERT(world!=0, "world was null! Call setWorld first!"); ASSERT(toolBarTools!=0, "toolBarTools was null"); ASSERT(toolBarMisc!=0, "toolBarMisc was null"); ASSERT(toolBarZone!=0, "toolBarZone was null"); ASSERT(mousePosLabel!=0, "mousePosLabel was null"); ASSERT(objectPalette!=0, "objectPalette was null"); ASSERT(tileTypeSelector!=0, "tileTypeSelector was null"); ASSERT(texturePalette_Wall!=0, "texturePalette_Wall was null"); ASSERT(texturePalette_Floor!=0, "texturePalette_Floor was null"); ASSERT(tileHeightSelector!=0, "tileHeightSelector was null"); if(g_Application.getState() == GAME_STATE_EDITOR) { toolBarTools->m_bVisible = true; toolBarMisc->m_bVisible = true; toolBarZone->m_bVisible = true; mousePosLabel->m_bVisible = true; // Hide the object palette (overridden by create tool) objectPalette->m_bVisible = false; // Hide the tile properties panel (overridden in map editor mode) toolBarTilePropreties->m_bVisible = false; // Get the point under the mouse cursor mousePos = getGroundPickPos(0.0f); // update the mouse cursor to show this position mousePosLabel->setLabel(string("Mouse: (") + ftoa(mousePos.x) + string(", ") + ftoa(mousePos.y) + string(", ") + ftoa(mousePos.z) + string(")")); if(g_Keys.isKeyDown(KEY_TEST)) { world->getMap().removeAllMaterials(); } // Update the tool bar widgets switch(toolBarTools->getTool()) { case ToolBarForEditorTools::EDITOR_CREATE_TOOL: // Show the object palette objectPalette->m_bVisible = true; // Decide the selected object { string o = chooseNextObject(); if(!o.empty()) { nextObject = o; } } break; case ToolBarForEditorTools::EDITOR_TILE_PENCIL_TOOL: toolBarTilePropreties->m_bVisible = true; // Update tile properties from the selectors tileEditor_wallTextureFile = chooseTileWallTexture(); tileEditor_floorTextureFile = chooseTileFloorTexture(); tileEditor_type = getTileType(); break; case ToolBarForEditorTools::EDITOR_TILE_BLOCK_TOOL: toolBarTilePropreties->m_bVisible = true; // Update tile properties from the selectors tileEditor_wallTextureFile = chooseTileWallTexture(); tileEditor_floorTextureFile = chooseTileFloorTexture(); tileEditor_type = getTileType(); // Has a drag stopped? if(!g_Input.MouseLeft) { // drag exitted if(drag) { // get a reference to the map Map &map = world->getMap(); // Get the position on the ground plane that the mouse was over vec3 groundPos = getGroundPickPos(0.0f); // Fill a block of tiles if(map.onATile(groundPos.x, groundPos.z) && map.onATile(mouseDownPos.x, mouseDownPos.z)) { map.fillBlock(groundPos.x, groundPos.z, mouseDownPos.x, mouseDownPos.z, tileEditor_type, tileEditor_properties, tileEditor_floorTextureFile, tileEditor_wallTextureFile, tileEditor_height); // Rebuild the map display list map.reaquire(); g_SoundSystem.play("data/sound/activate.wav"); } } drag = false; } break; case ToolBarForEditorTools::EDITOR_DESTROY_TOOL: // (This tool doesn't require updating every tick) break; case ToolBarForEditorTools::EDITOR_ROTATE_TOOL: // (This tool doesn't require updating every tick) break; case ToolBarForEditorTools::EDITOR_ROTATE_X_TOOL: // (This tool doesn't require updating every tick) break; case ToolBarForEditorTools::EDITOR_ROTATE_Z_TOOL: // (This tool doesn't require updating every tick) break; case ToolBarForEditorTools::EDITOR_MOVE_TOOL: // (This tool doesn't require updating every tick) break; case ToolBarForEditorTools::EDITOR_SELECT_TOOL: // (This tool doesn't require updating every tick) break; }; // The tile selectors cannot be opened if the tile properties dialog is not if(toolBarTilePropreties->m_bVisible) { switch(textureSelectorState) { case TEXTURE_SELECTOR_HIDE: texturePalette_Wall->m_bVisible = false; texturePalette_Floor->m_bVisible = false; break; case TEXTURE_SELECTOR_FLOOR: texturePalette_Wall->m_bVisible = false; texturePalette_Floor->m_bVisible = true; break; case TEXTURE_SELECTOR_WALL: texturePalette_Wall->m_bVisible = true; texturePalette_Floor->m_bVisible = false; break; }; } else { tileTypeSelector->m_bVisible = false; tileHeightSelector->m_bVisible = false; textureSelectorState = TEXTURE_SELECTOR_HIDE; texturePalette_Wall->m_bVisible = false; texturePalette_Floor->m_bVisible = false; } // In editor mode, only update the selected object if(selected) selected->updateForEditor(deltaTime); // Call the event handler for left-click if(g_Input.MouseLeft) { onLeftMouseDown(); } else { leftClickDebounce=false; } // Save / Load the game if(shouldSave) { world->saveToFile(); } else if(shouldLoad) { world->loadFromFile(); } else if(shouldNew) { createNewMap(); } } else {// None of these should be visible in game mode toolBarTools->m_bVisible = false; toolBarMisc->m_bVisible = false; mousePosLabel->m_bVisible = false; objectPalette->m_bVisible = false; toolBarZone->m_bVisible = false; // Hide tile properties dialogs toolBarTilePropreties->m_bVisible = false; tileTypeSelector->m_bVisible = false; tileHeightSelector->m_bVisible = false; texturePalette_Wall->m_bVisible = false; texturePalette_Floor->m_bVisible = false; tileHeightSelector->m_bVisible = false; } // reset each tick shouldSave = false; shouldLoad = false; shouldNew = false; }