void BrushToolInputState::OnExit() { EditorState* owner = GetOwnerDerived(); // Hide the tile palette. owner->GetTilePalette()->Hide(); }
void Game::handleEvent(Event& e) { if(strcmp(e.getID(), "changestate") == 0) { if(strcmp(e[0].toChar(), "menu") == 0) { MenuState* pMenuState = dynamic_cast<MenuState*>(m_pStateManager->initState(new MenuState())); pMenuState->Initialize(); m_pStateManager->setActiveState(pMenuState); } else if(strcmp(e[0].toChar(), "game") == 0) { SPGameState* pGameState = dynamic_cast<SPGameState*>(m_pStateManager->initState(new SPGameState())); pGameState->Initialize(); m_pStateManager->setActiveState(pGameState); } else if(strcmp(e[0].toChar(), "editor") == 0) { EditorState* pEditorState = dynamic_cast<EditorState*>(m_pStateManager->initState(new EditorState())); pEditorState->Initialize(); m_pStateManager->setActiveState(pEditorState); } } }
void PlaceToolInputState::OnDraw() { if( mUnitPlacementSprite ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); // Draw the Unit placement sprite. mUnitPlacementSprite->OnDraw( *mapView->GetCamera() ); } }
bool PlaceToolInputState::OnPointerDown( const Pointer& pointer ) { // Make sure there is a valid UnitType and Faction selected. if( mSelectedUnitType && mSelectedFaction && pointer.IsActivePointer() ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); // If this is the active pointer, create a new Unit placement sprite under it. CreateUnitPlacementSprite( mapView->ScreenToWorldCoords( pointer.position ) ); } return false; //InputState::OnPointerDown( pointer ); }
void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePostLayoutDataHint shouldIncludePostLayoutData) const { if (shouldIncludePostLayoutData == IncludePostLayoutDataHint::No) { result.isMissingPostLayoutData = true; return; } auto& postLayoutData = result.postLayoutData(); postLayoutData.caretRectAtStart = frame.selection().absoluteCaretBounds(); const VisibleSelection& selection = frame.selection().selection(); if (selection.isNone()) return; const Editor& editor = frame.editor(); if (selection.isRange()) { if (editor.selectionHasStyle(CSSPropertyFontWeight, "bold") == TrueTriState) postLayoutData.typingAttributes |= AttributeBold; if (editor.selectionHasStyle(CSSPropertyFontStyle, "italic") == TrueTriState) postLayoutData.typingAttributes |= AttributeItalics; if (editor.selectionHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "underline") == TrueTriState) postLayoutData.typingAttributes |= AttributeUnderline; if (editor.selectionHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "line-through") == TrueTriState) postLayoutData.typingAttributes |= AttributeStrikeThrough; } else if (selection.isCaret()) { if (editor.selectionStartHasStyle(CSSPropertyFontWeight, "bold")) postLayoutData.typingAttributes |= AttributeBold; if (editor.selectionStartHasStyle(CSSPropertyFontStyle, "italic")) postLayoutData.typingAttributes |= AttributeItalics; if (editor.selectionStartHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "underline")) postLayoutData.typingAttributes |= AttributeUnderline; if (editor.selectionStartHasStyle(CSSPropertyWebkitTextDecorationsInEffect, "line-through")) postLayoutData.typingAttributes |= AttributeStrikeThrough; } }
void EraserToolInputState::DestroyUnitAtScreenCoords( const Vec2f& screenCoords ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); Map* map = owner->GetMap(); // Get the UnitSprite under the pointer (if any). UnitSprite* unitSprite = mapView->GetUnitSpriteAtScreenCoords( screenCoords ); if( unitSprite ) { // If there is a Unit under the pointer, destroy it. Unit* unit = unitSprite->GetUnit(); DebugPrintf( "Erasing UnitSprite at Tile (%d,%d)!", unit->GetTileX(), unit->GetTileY() ); map->DestroyUnit( unit ); } }
bool PlaceToolInputState::OnPointerMotion( const Pointer& activePointer, const PointersByID& pointersByID ) { bool wasHandled = false; //InputState::OnPointerMotion( activePointer, pointersByID ); if( !wasHandled && mUnitPlacementSprite && activePointer.isMoving ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); // Move the Unit placement Sprite to the position of the active pointer. MoveUnitPlacementSprite( mapView->ScreenToWorldCoords( activePointer.position ) ); wasHandled = true; } return wasHandled; }
void BrushToolInputState::OnEnter( const Dictionary& parameters ) { EditorState* owner = GetOwnerDerived(); // Get the selected Tile template (if specified). Tile tileTemplate; Dictionary::DictionaryError error = parameters.Get( "tileTemplate", tileTemplate ); if( error == Dictionary::DErr_SUCCESS ) { // Set the selected Tile template. SetTileTemplate( tileTemplate ); } // Show the tile palette. owner->GetTilePalette()->Show(); }
Unit* PlaceToolInputState::CreateUnitAtScreenCoords( const Vec2f& screenCoords ) { Unit* unit = nullptr; if( mSelectedUnitType ) { if( mSelectedFaction ) { EditorState* owner = GetOwnerDerived(); MapView* mapView = owner->GetMapView(); Map* map = owner->GetMap(); // Get the Tile at the screen coords. Vec2f worldPos = mapView->ScreenToWorldCoords( screenCoords ); Vec2s tilePos = mapView->WorldToTileCoords( worldPos ); Map::Iterator tile = map->GetTile( tilePos ); if( tile.IsValid() && tile->IsEmpty() && mSelectedUnitType->CanMoveAcrossTerrain( tile->GetTerrainType() ) ) { // If the selected UnitType can be placed into the Tile, create a new Unit. DebugPrintf( "Placing Unit at tile (%d,%d)!", tilePos.x, tilePos.y ); unit = map->CreateUnit( mSelectedUnitType, mSelectedFaction, tilePos ); } else { WarnFail( "Cannot place Unit into tile (%d,%d)!", tilePos.x, tilePos.y ); } } else { WarnFail( "Cannot create Unit because no Faction was selected!" ); } } else { WarnFail( "Cannot create Unit because no UnitType was selected!" ); } return unit; }
bool EditorState::decode(IPC::ArgumentDecoder& decoder, EditorState& result) { if (!decoder.decode(result.shouldIgnoreCompositionSelectionChange)) return false; if (!decoder.decode(result.selectionIsNone)) return false; if (!decoder.decode(result.selectionIsRange)) return false; if (!decoder.decode(result.isContentEditable)) return false; if (!decoder.decode(result.isContentRichlyEditable)) return false; if (!decoder.decode(result.isInPasswordField)) return false; if (!decoder.decode(result.isInPlugin)) return false; if (!decoder.decode(result.hasComposition)) return false; if (!decoder.decode(result.isMissingPostLayoutData)) return false; #if PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(MAC) if (!result.isMissingPostLayoutData) { if (!PostLayoutData::decode(decoder, result.postLayoutData())) return false; } #endif #if PLATFORM(IOS) if (!decoder.decode(result.firstMarkedRect)) return false; if (!decoder.decode(result.lastMarkedRect)) return false; if (!decoder.decode(result.markedText)) return false; #endif return true; }
void editorInit() { editor_state.init(); createHeightmapTileset(); }