void CInMapDraw::MousePress(int x, int y, int button) { float3 pos=GetMouseMapPos(); if(pos.x<0) return; switch(button){ case SDL_BUTTON_LEFT: if(lastLeftClickTime>gu->gameTime-0.3){ waitingPoint=pos; game->userWriting=true; wantLabel=true; game->userPrompt="Label: "; game->ignoreChar='\xA7'; //should do something better here } lastLeftClickTime=gu->gameTime; break; case SDL_BUTTON_RIGHT: ErasePos(pos); break; case SDL_BUTTON_MIDDLE:{ CreatePoint(pos,""); break;} } lastPos=pos; }
void CInMapDraw::MousePress(int x, int y, int button) { float3 pos = GetMouseMapPos(); if (pos.x < 0) return; switch (button) { case SDL_BUTTON_LEFT: { if (lastLeftClickTime > gu->gameTime - 0.3f) { PromptLabel(pos); } lastLeftClickTime = gu->gameTime; break; } case SDL_BUTTON_RIGHT: { SendErase(pos); break; } case SDL_BUTTON_MIDDLE:{ SendPoint(pos, "", false); break; } } lastPos = pos; }
void RenderEditorInfo( ) { wchar_t FPSText[ 50 ]; static INT32 iSpewWarning = 0; INT16 iMapIndex; SetFont( FONT12POINT1 ); SetFontForeground( FONT_BLACK ); SetFontBackground( FONT_BLACK ); //Display the mapindex position if( GetMouseMapPos( &iMapIndex ) ) swprintf( FPSText, L" (%d) ", iMapIndex ); else swprintf( FPSText, L" " ); mprintfEditor( (UINT16)(50-StringPixLength( FPSText, FONT12POINT1 )/2), 463, FPSText ); switch( iCurrentTaskbar ) { case TASK_OPTIONS: if( !gfWorldLoaded || giCurrentTilesetID < 0 ) mprintf( 260, 445, L"No map currently loaded." ); else mprintf( 260, 445, L"File: %S, Current Tileset: %s", gubFilename, gTilesets[ giCurrentTilesetID ].zName ); break; case TASK_TERRAIN: if( gusSelectionType == LINESELECTION ) swprintf( wszSelType[LINESELECTION], L"Width: %d", gusSelectionWidth ); DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, 220, 430, 60, 30 ); swprintf( FPSText, L"%d%%", gusSelectionDensity ); DrawEditorInfoBox( FPSText, FONT12POINT1, 310, 430, 40, 30 ); break; case TASK_ITEMS: RenderEditorItemsInfo(); UpdateItemStatsPanel(); break; case TASK_BUILDINGS: UpdateBuildingsInfo(); if( gusSelectionType == LINESELECTION ) swprintf( wszSelType[LINESELECTION], L"Width: %d", gusSelectionWidth ); DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, 530, 430, 60, 30 ); break; case TASK_MERCS: UpdateMercsInfo(); break; case TASK_MAPINFO: UpdateMapInfo(); if( gusSelectionType == LINESELECTION ) swprintf( wszSelType[LINESELECTION], L"Width: %d", gusSelectionWidth ); DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, 440, 430, 60, 30 ); break; } }
void cUIMap::DragPoly( Uint32 Flags, Uint32 PFlags ) { if ( ( PFlags & EE_BUTTON_MMASK ) && NULL != mSelObj ) { if ( mSelObj->PointInside( mMap->GetMouseMapPosf() ) ) { if ( !mObjDragging ) { mObjDragging = true; mObjDragDist = GetMouseMapPos() - mSelObj->Pos(); } } mSelObj->Pos( GetMouseMapPos() - mObjDragDist ); if ( EDIT_POLYGONS == mEditingObjMode ) { SelectPolyPoint(); } } else if ( Flags & EE_BUTTON_MMASK ) { if ( mObjDragging ) { mObjDragging = false; mObjDragDist = eeVector2f(0,0); } } }
void CInMapDraw::MouseMove(int x, int y, int dx,int dy, int button) { float3 pos=GetMouseMapPos(); if(pos.x<0) return; if(mouse->buttons[SDL_BUTTON_LEFT].pressed && lastLineTime<gu->gameTime-0.05){ AddLine(pos,lastPos); lastLineTime=gu->gameTime; lastPos=pos; } if(mouse->buttons[SDL_BUTTON_RIGHT].pressed) ErasePos(pos); }
void CInMapDraw::MouseMove(int x, int y, int dx, int dy, int button) { float3 pos = GetMouseMapPos(); if (pos.x < 0) { return; } if (mouse->buttons[SDL_BUTTON_LEFT].pressed && (lastDrawTime < (gu->gameTime - 0.05f))) { SendLine(pos, lastPos, false); lastDrawTime = gu->gameTime; lastPos = pos; } if (mouse->buttons[SDL_BUTTON_RIGHT].pressed && (lastDrawTime < (gu->gameTime - 0.05f))) { SendErase(pos); lastDrawTime = gu->gameTime; } }
void cUIMap::MapDraw() { if ( EDITING_LIGHT == mEditingMode ) { if ( NULL != mSelLight ) { mP.SetColor( eeColorA( 255, 0, 0, (Uint8)mAlpha ) ); eeVector2f Pos( mSelLight->GetAABB().Left, mSelLight->GetAABB().Top ); eeAABB AB( mSelLight->GetAABB() ); mP.FillMode( DRAW_LINE ); mP.DrawRectangle( eeRectf( Pos, AB.Size() ) ); } } else if ( EDITING_OBJECT == mEditingMode ) { switch ( mEditingObjMode ) { case INSERT_OBJECT: { if ( mObjRECTEditing ) { mP.FillMode( DRAW_FILL ); mP.SetColor( eeColorA( 100, 100, 100, 20 ) ); mP.DrawRectangle( mObjRECT ); mP.FillMode( DRAW_LINE ); mP.SetColor( eeColorA( 255, 0, 0, 200 ) ); mP.DrawRectangle( mObjRECT ); } break; } case INSERT_POLYGON: { mP.FillMode( DRAW_FILL ); mP.SetColor( eeColorA( 50, 50, 50, 50 ) ); mP.DrawPolygon( mObjPoly ); mP.FillMode( DRAW_LINE ); mP.SetColor( eeColorA( 255, 0, 0, 200 ) ); mP.DrawPolygon( mObjPoly ); eePolygon2f polyN( mObjPoly ); polyN.PushBack( GetMouseMapPos() ); mP.FillMode( DRAW_FILL ); mP.SetColor( eeColorA( 100, 100, 100, 100 ) ); mP.DrawPolygon( polyN ); mP.FillMode( DRAW_LINE ); mP.SetColor( eeColorA( 255, 255, 0, 200 ) ); mP.DrawPolygon( polyN ); break; } case INSERT_POLYLINE: { mP.FillMode( DRAW_LINE ); mP.SetColor( eeColorA( 255, 0, 0, 200 ) ); mP.DrawPolygon( mObjPoly ); eePolygon2f polyN( mObjPoly ); polyN.PushBack( GetMouseMapPos() ); mP.FillMode( DRAW_LINE ); mP.SetColor( eeColorA( 255, 255, 0, 200 ) ); mP.DrawPolygon( polyN ); break; } case EDIT_POLYGONS: { if ( NULL != mSelObj && eeINDEX_NOT_FOUND != mSelPointIndex ) { mP.SetColor( eeColorA( 255, 255, 100, 100 ) ); mP.FillMode( DRAW_FILL ); mP.DrawRectangle( mSelPointRect ); mP.FillMode( DRAW_LINE ); mP.DrawRectangle( mSelPointRect ); } break; } } } }
void cUIMap::ManageObject( Uint32 Flags ) { Uint32 PFlags = cUIManager::instance()->GetInput()->PressTrigger(); Uint32 LPFlags = cUIManager::instance()->GetInput()->LastPressTrigger(); switch ( mEditingObjMode ) { case INSERT_OBJECT: { if ( PFlags & EE_BUTTON_LMASK ) { eeVector2f mp( GetMouseMapPos() ); if ( !mObjRECTEditing ) { mObjRECTEditing = true; mObjRECT = eeRectf( mp, eeSizef(0,0) ); } else { if ( mObjRECT.Pos().x < mp.x && mObjRECT.Pos().y < mp.y ) { mObjRECT = eeRectf( mObjRECT.Pos(), eeSizef( mp - mObjRECT.Pos() ) ); } } } if ( Flags & EE_BUTTON_LMASK ){ if ( mObjRECTEditing ) { mAddObjectCallback( GAMEOBJECT_TYPE_OBJECT, eePolygon2f( mObjRECT ) ); mObjRECTEditing = false; } } break; } case INSERT_POLYLINE: case INSERT_POLYGON: { if ( Flags & EE_BUTTON_LMASK ) { mObjPoly.PushBack( GetMouseMapPos() ); } else if ( Flags & EE_BUTTON_RMASK ) { mAddObjectCallback( ( INSERT_POLYGON == mEditingObjMode ) ? GAMEOBJECT_TYPE_POLYGON : GAMEOBJECT_TYPE_POLYLINE, mObjPoly ); mObjPoly.Clear(); } break; } case SELECT_OBJECTS: { if ( ( Flags & EE_BUTTON_LMASK ) ) { SelectPolyObj(); } else { DragPoly( Flags, PFlags ); } break; } case EDIT_POLYGONS: { if ( ( Flags & EE_BUTTON_LMASK ) ) { if ( !mSelPoint ) { SelectPolyObj(); SelectPolyPoint(); } else { mSelPoint = false; } } else if ( !( LPFlags & EE_BUTTON_LMASK ) && ( PFlags & EE_BUTTON_LMASK ) ) { if ( NULL != mSelObj && eeINDEX_NOT_FOUND != mSelPointIndex && mSelPointRect.Contains( mMap->GetMouseMapPosf() ) ) { mSelPoint = true; } } else if ( ( PFlags & EE_BUTTON_LMASK ) ) { if ( mSelPoint && NULL != mSelObj && eeINDEX_NOT_FOUND != mSelPointIndex ) { mSelObj->SetPolygonPoint( mSelPointIndex, GetMouseMapPos() ); SetPointRect( GetMouseMapPos() ); } } else { DragPoly( Flags, PFlags ); } break; } default: { } } }
void RenderEditorInfo( ) { CHAR16 FPSText[ 50 ]; static INT32 iSpewWarning = 0; INT32 iMapIndexD; //dnl ch52 091009 SetFont(FONT12ARIAL); SetFontShadow(FONT_NEARBLACK); SetFontForeground(FONT_GRAY2); SetFontBackground(FONT_BLACK); //dnl ch1 101009 Display the mapindex position if(GetMouseMapPos(&iMapIndexD)) { INT16 sGridX, sGridY; GetMouseXY(&sGridX, &sGridY); swprintf(FPSText, L"%4d %4d %6d ", sGridX, sGridY, iMapIndexD); } else swprintf(FPSText, L" "); mprintfEditor( (UINT16)(iScreenWidthOffset + 50-StringPixLength( FPSText, FONT12POINT1 )/2), 2 * iScreenHeightOffset + 463, FPSText ); switch( iCurrentTaskbar ) { case TASK_OPTIONS: mprintf(iScreenWidthOffset+71+15, SCREEN_HEIGHT-117, iRenderEditorInfoText[0]);//dnl ch33 160909 if( !gfWorldLoaded || giCurrentTilesetID < 0 ) mprintf( iScreenWidthOffset + 260, 2 * iScreenHeightOffset + 445, iRenderEditorInfoText[1] ); else mprintf( iScreenWidthOffset + 260, 2 * iScreenHeightOffset + 445, iRenderEditorInfoText[2], gubFilename, gTilesets[ giCurrentTilesetID ].zName ); // TODO.MAP mprintf(iScreenWidthOffset+20, SCREEN_HEIGHT-40, iRenderEditorInfoText[3]); UpdateOptions(); break; case TASK_TERRAIN: // WANNE: Comment this two lines, because we always get an exception here. //if( gusSelectionType == LINESELECTION ) // swprintf( wszSelType[LINESELECTION], L"Width: %d", gusSelectionWidth ); DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, iScreenWidthOffset + 220, 2 * iScreenHeightOffset + 430, 60, 30 ); swprintf( FPSText, L"%d%%", gusSelectionDensity ); DrawEditorInfoBox( FPSText, FONT12POINT1, iScreenWidthOffset + 310, 2 * iScreenHeightOffset + 430, 40, 30 ); break; case TASK_ITEMS: RenderEditorItemsInfo(); UpdateItemStatsPanel(); break; case TASK_BUILDINGS: UpdateBuildingsInfo(); // WANNE: Comment this two lines, because we always get an exception here. //if( gusSelectionType == LINESELECTION ) // swprintf( wszSelType[LINESELECTION], L"%d", gusSelectionWidth ); DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, iScreenWidthOffset + 530, 2 * iScreenHeightOffset + 430, 60, 30 ); break; case TASK_MERCS: UpdateMercsInfo(); #ifdef JA113DEMO DisableButton (iEditorButton[ MERCS_CIVILIANTOGGLE ]); DisableButton (iEditorButton[ MERCS_CIVILIAN ]); #endif break; case TASK_MAPINFO: UpdateMapInfo(); // WANNE: EDITOR: Comment this two lines, because we always get an exception here! //if( gusSelectionType == LINESELECTION ) // swprintf( wszSelType[LINESELECTION], L"Width: %d", gusSelectionWidth ); DrawEditorInfoBox( wszSelType[gusSelectionType], FONT12POINT1, iScreenWidthOffset + 440, 2 * iScreenHeightOffset + 430, 60, 30 ); break; } }
void DetermineCursorBodyLocation( UINT8 ubSoldierID, BOOLEAN fDisplay, BOOLEAN fRecalc ) { UINT16 usMapPos; SOLDIERTYPE *pTargetSoldier = NULL, *pSoldier; UINT16 usFlags; INT16 sMouseX, sMouseY, sCellX, sCellY, sScreenX, sScreenY; BOOLEAN fOnGuy = FALSE; LEVELNODE *pNode; pSoldier = MercPtrs[ ubSoldierID ]; if ( gTacticalStatus.ubAttackBusyCount > 0 ) { // ATE: Return if attacker busy count > 0, this // helps in RT with re-setting the flag to random... return; } if ( fRecalc ) { // ALWAYS SET AIM LOCATION TO NOTHING pSoldier->bAimShotLocation = AIM_SHOT_RANDOM; if( !GetMouseMapPos( &usMapPos) ) { return; } // Determine which body part it's on pNode = GetAnimProfileFlags( usMapPos, &usFlags, &pTargetSoldier, NULL ); while( pNode != NULL ) { if ( pTargetSoldier != NULL ) { // ATE: Check their stance - if prone - return! if ( gAnimControl[ pTargetSoldier->usAnimState ].ubHeight == ANIM_PRONE ) { return; } fOnGuy = TRUE; // Check if we have a half tile profile if ( usFlags & TILE_FLAG_NORTH_HALF ) { // Check if we are in north half of tile! GetMouseXYWithRemainder( &sMouseX, &sMouseY, &sCellX, &sCellY ); if ( sCellY > (CELL_Y_SIZE / 2) ) { fOnGuy = FALSE; } } // Check if we have a half tile profile if ( usFlags & TILE_FLAG_SOUTH_HALF ) { // Check if we are in north half of tile! GetMouseXYWithRemainder( &sMouseX, &sMouseY, &sCellX, &sCellY ); if ( sCellY <= (CELL_Y_SIZE / 2) ) { fOnGuy = FALSE; } } // Check if we have a half tile profile if ( usFlags & TILE_FLAG_WEST_HALF ) { // Check if we are in north half of tile! GetMouseXYWithRemainder( &sMouseX, &sMouseY, &sCellX, &sCellY ); if ( sCellX > (CELL_X_SIZE / 2) ) { fOnGuy = FALSE; } } if ( usFlags & TILE_FLAG_EAST_HALF ) { // Check if we are in north half of tile! GetMouseXYWithRemainder( &sMouseX, &sMouseY, &sCellX, &sCellY ); if ( sCellX <= (CELL_X_SIZE / 2) ) { fOnGuy = FALSE; } } if ( usFlags & TILE_FLAG_TOP_HALF ) { // Check if we are in north half of tile! GetMouseXYWithRemainder( &sMouseX, &sMouseY, &sCellX, &sCellY ); // Convert these to screen corrdinates FromCellToScreenCoordinates( sCellX, sCellY, &sScreenX, &sScreenY ); // Check for Below... if ( sScreenX > (WORLD_TILE_Y / 2) ) { fOnGuy = FALSE; } } if ( usFlags & TILE_FLAG_BOTTOM_HALF ) { // Check if we are in north half of tile! GetMouseXYWithRemainder( &sMouseX, &sMouseY, &sCellX, &sCellY ); // Convert these to screen corrdinates FromCellToScreenCoordinates( sCellX, sCellY, &sScreenX, &sScreenY ); // Check for Below... if ( sScreenX <= (WORLD_TILE_Y / 2) ) { fOnGuy = FALSE; } } // Check if mouse is iin bounding box of soldier if ( !IsPointInSoldierBoundingBox( pTargetSoldier, gusMouseXPos, gusMouseYPos ) ) { fOnGuy = FALSE; } } if ( fOnGuy ) break; pNode = GetAnimProfileFlags( usMapPos, &usFlags, &pTargetSoldier, pNode ); } if ( !fOnGuy ) { // Check if we can find a soldier here if ( gfUIFullTargetFound ) { pTargetSoldier = MercPtrs[ gusUIFullTargetID ]; if ( FindRelativeSoldierPosition( pTargetSoldier, &usFlags, gusMouseXPos, gusMouseYPos ) ) { fOnGuy = TRUE; } } } if ( fOnGuy ) { if ( IsValidTargetMerc( pTargetSoldier->ubID ) ) { if ( usFlags & TILE_FLAG_FEET ) { pSoldier->bAimShotLocation = AIM_SHOT_LEGS; } if ( usFlags & TILE_FLAG_MID ) { pSoldier->bAimShotLocation = AIM_SHOT_TORSO; } if ( usFlags & TILE_FLAG_HEAD ) { pSoldier->bAimShotLocation = AIM_SHOT_HEAD; } } } } if ( fDisplay && ( !pSoldier->bDoBurst ) ) { if ( gfUIFullTargetFound ) { pTargetSoldier = MercPtrs[ gusUIFullTargetID ]; if ( pTargetSoldier->ubBodyType == CROW ) { pSoldier->bAimShotLocation = AIM_SHOT_LEGS; wcscpy( gzLocation, TacticalStr[ CROW_HIT_LOCATION_STR ] ); gfUIBodyHitLocation = TRUE; return; } if ( !IS_MERC_BODY_TYPE( pTargetSoldier ) ) { return; } switch( pSoldier->bAimShotLocation ) { case AIM_SHOT_HEAD: // If we have a knife in hand, change string if ( Item[ pSoldier->inv[ HANDPOS ].usItem ].usItemClass == IC_BLADE ) { wcscpy( gzLocation, TacticalStr[ NECK_HIT_LOCATION_STR ] ); } else { wcscpy( gzLocation, TacticalStr[ HEAD_HIT_LOCATION_STR ] ); } gfUIBodyHitLocation = TRUE; break; case AIM_SHOT_TORSO: wcscpy( gzLocation, TacticalStr[ TORSO_HIT_LOCATION_STR ] ); gfUIBodyHitLocation = TRUE; break; case AIM_SHOT_LEGS: wcscpy( gzLocation, TacticalStr[ LEGS_HIT_LOCATION_STR ] ); gfUIBodyHitLocation = TRUE; break; } } } }
void HandleLeftClickCursor( SOLDIERTYPE *pSoldier ) { UINT16 usInHand; UINT8 ubItemCursor; INT16 sGridNo; // LOOK IN GUY'S HAND TO CHECK LOCATION usInHand = pSoldier->inv[HANDPOS].usItem; ubItemCursor = GetActionModeCursor( pSoldier ); // OK, if we are i realtime.. goto directly to shoot if ( ( ( gTacticalStatus.uiFlags & TURNBASED ) && !( gTacticalStatus.uiFlags & INCOMBAT ) ) && ubItemCursor != TOSSCURS && ubItemCursor != TRAJECTORYCURS ) { // GOTO DIRECTLY TO USING ITEM // ( only if not burst mode.. ) if ( !pSoldier->bDoBurst ) { guiPendingOverrideEvent = CA_MERC_SHOOT; } return; } if (!GetMouseMapPos( &sGridNo ) ) { return; } gfUIForceReExamineCursorData = TRUE; gfDisplayFullCountRing = FALSE; switch( ubItemCursor ) { case TARGETCURS: if ( gTacticalStatus.uiFlags & TURNBASED && (gTacticalStatus.uiFlags & INCOMBAT ) ) { pSoldier->bShownAimTime = REFINE_AIM_1; pSoldier->fPauseAim = FALSE; } else { pSoldier->bShownAimTime = REFINE_AIM_1; pSoldier->fPauseAim = FALSE; } // Reset counter RESETCOUNTER( TARGETREFINE ); break; case PUNCHCURS: if ( gTacticalStatus.uiFlags & TURNBASED && (gTacticalStatus.uiFlags & INCOMBAT ) ) { pSoldier->bShownAimTime = REFINE_PUNCH_1; pSoldier->fPauseAim = FALSE; } else { pSoldier->bShownAimTime = REFINE_PUNCH_1; pSoldier->fPauseAim = FALSE; } // Reset counter RESETCOUNTER( NONGUNTARGETREFINE ); break; case KNIFECURS: if ( gTacticalStatus.uiFlags & TURNBASED && (gTacticalStatus.uiFlags & INCOMBAT ) ) { pSoldier->bShownAimTime = REFINE_KNIFE_1; pSoldier->fPauseAim = FALSE; } else { pSoldier->bShownAimTime = REFINE_KNIFE_1; pSoldier->fPauseAim = FALSE; } // Reset counter RESETCOUNTER( NONGUNTARGETREFINE ); break; case TOSSCURS: //BeginAimCubeUI( pSoldier, sGridNo, (INT8)gsInterfaceLevel, 0, 0 ); //break; default: // GOTO DIRECTLY TO USING ITEM guiPendingOverrideEvent = CA_MERC_SHOOT; } }