Esempio n. 1
0
/**
**  Begin input.
*/
static void UiBeginInput()
{
	KeyState = KeyStateInput;
	Input[0] = '\0';
	InputIndex = 0;
	ClearCosts();
	ShowInput();
}
Esempio n. 2
0
/**
**	Cancel building cursor mode.
*/
global void CancelBuildingMode(void)
{
    CursorBuilding=NULL;
    MustRedraw|=RedrawCursor;
    ClearStatusLine();
    ClearCosts();
    CurrentButtonLevel = 0; // reset unit buttons to normal
    UpdateBottomPanel();
}
Esempio n. 3
0
/**
**  Run the set-selection-changed-hook.
*/
void SelectionChanged()
{
	// We Changed out selection, anything pending buttonwise must be cleared
	UI.StatusLine.Clear();
	ClearCosts();
	CurrentButtonLevel = 0;
	LastDrawnButtonPopup = NULL;

	UI.ButtonPanel.Update();
	GameCursor = UI.Point.Cursor;
	CursorBuilding = NULL;
	CursorState = CursorStatePoint;
	UI.ButtonPanel.Update();
}
Esempio n. 4
0
/**
**  Find the next idle worker, select it, and center on it
*/
static void UiFindIdleWorker()
{
	if (ThisPlayer->FreeWorkers.empty()) {
		return;
	}
	CUnit *unit = ThisPlayer->FreeWorkers[0];

	if (unit != NULL) {
		SelectSingleUnit(*unit);
		UI.StatusLine.Clear();
		ClearCosts();
		CurrentButtonLevel = 0;
		PlayUnitSound(*Selected[0], VoiceSelected);
		SelectionChanged();
		UI.SelectedViewport->Center(unit->GetMapPixelPosCenter());
	}
}
Esempio n. 5
0
/**
**	Draw bottom panel.
*/
global void DrawBottomPanel(void)
{
    int i;
    int v;
    const UnitStats* stats;
    const ButtonAction* buttons;

    DrawImage(ImagePanelBottom,0,0,0,336);

    if( !(buttons=CurrentButtons) ) {	// no buttons
	return;
    }

    for( i=0; i<9; ++i ) {
	if( buttons[i].Pos!=-1 ) {
	    // cursor is on that button
	    if( ButtonUnderCursor==i+10 ) {
		v=IconActive;
		if( MouseButtons&LeftButton ) {
		    v=IconClicked;
		}
	    } else {
		v=0;
	    }
	    //
	    //	Any better ideas?
	    //	Show the current action state of the unit
	    //	with the buttons.
	    //
	    if( NumSelected==1 ) {
		switch( buttons[i].Action ) {
		    case B_Stop:
			if( Selected[0]->Command.Action==UnitActionStill ) {
			    v=IconSelected;
			}
			break;
		    case B_StandGround:
			if( Selected[0]->Command.Action
				==UnitActionStandGround ) {
			    v=IconSelected;
			}
			break;
		    case B_Move:
			if( Selected[0]->Command.Action==UnitActionMove ) {
			    v=IconSelected;
			}
			break;
		    case B_Attack:
			if( Selected[0]->Command.Action==UnitActionAttack ) {
			    v=IconSelected;
			}
			break;
		    case B_Demolish:
			if( Selected[0]->Command.Action==UnitActionDemolish ) {
			    v=IconSelected;
			}
			break;
/* FIXME: attackground and attack are both ActionAttack
		    case B_AttackGround:
			if( Selected[0]->Command.Action==UnitActionAttack ) {
			    v=IconSelected;
			}
			break;
*/

		    // FIXME: must handle more actions

		    default:
			break;
		}
	    }

	    DrawUnitIcon(buttons[i].Icon.Icon
		    ,v,Buttons[i+10].X,Buttons[i+10].Y);

	    //
	    //	Update status line for this button
	    //
	    if( ButtonUnderCursor==i+10 ) {
		SetStatusLine(buttons[i].Hint);
		// FIXME: Draw costs
		v=buttons[i].Value;
		switch( buttons[i].Action ) {
		    case B_Build:
		    case B_Train:
		    case B_UpgradeTo:
			stats=&UnitTypes[v].Stats[ThisPlayer->Player];
			SetCosts(0,stats->Costs[GoldCost]
				,stats->Costs[WoodCost]
				,stats->Costs[OilCost]);
			break;
		    //case B_Upgrade:
		    case B_Research:
			SetCosts(0
				/*Upgrades[v].Costs[ManaCost]*/
				,Upgrades[v].Costs[GoldCost]
				,Upgrades[v].Costs[WoodCost]
				,Upgrades[v].Costs[OilCost]);
			break;
		    case B_Magic:
			// FIXME: correct costs!!!
			SetCosts(11 ,0,0,0);
			break;

		    default:
			ClearCosts();
			break;
		}
	    }
	}
    }
}