Redraw entire screen every frame
This commit is contained in:
parent
a9f51bfc43
commit
4cd7e7f76c
50 changed files with 102 additions and 1335 deletions
|
@ -147,9 +147,6 @@ local Unit* CheckForDeadGoal(Unit* unit)
|
|||
unit->SavedOrder.Action = UnitActionStill;
|
||||
unit->SavedOrder.Goal = NoUnitP;
|
||||
|
||||
if (unit->Selected && unit->Player == ThisPlayer) {
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
}
|
||||
goal = unit->Orders[0].Goal;
|
||||
}
|
||||
NewResetPath(unit);
|
||||
|
@ -286,8 +283,6 @@ local void MoveToTarget(Unit* unit)
|
|||
UnitHeadingFromDeltaXY(unit,
|
||||
goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
|
||||
goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);
|
||||
// FIXME: only if heading changes
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
unit->SubAction++;
|
||||
return;
|
||||
|
@ -304,8 +299,6 @@ local void MoveToTarget(Unit* unit)
|
|||
if (unit->Stats->Speed) {
|
||||
UnitHeadingFromDeltaXY(unit, unit->Orders[0].X - unit->X,
|
||||
unit->Orders[0].Y - unit->Y);
|
||||
// FIXME: only if heading changes
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
unit->SubAction &= WEAK_TARGET;
|
||||
unit->SubAction |= ATTACK_TARGET;
|
||||
|
@ -351,9 +344,6 @@ local void MoveToTarget(Unit* unit)
|
|||
unit->SavedOrder.Action = UnitActionStill;
|
||||
unit->SavedOrder.Goal = NoUnitP;
|
||||
|
||||
if (unit->Selected && unit->Player == ThisPlayer) {
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
}
|
||||
return;
|
||||
}
|
||||
DebugCheck(unit->Type->Vanishes || unit->Destroyed || unit->Removed);
|
||||
|
@ -423,10 +413,6 @@ local void AttackTarget(Unit* unit)
|
|||
|
||||
// This isn't supported
|
||||
DebugCheck(unit->SavedOrder.Goal != NoUnitP);
|
||||
|
||||
if (unit->Selected && unit->Player == ThisPlayer) {
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -522,8 +508,6 @@ local void AttackTarget(Unit* unit)
|
|||
UnitHeadingFromDeltaXY(unit,
|
||||
goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
|
||||
goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);
|
||||
// FIXME: only if heading changes
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,7 +169,6 @@ local void EnterTransporter(Unit* unit)
|
|||
|
||||
if (IsOnlySelected(transporter)) {
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ local void UpdateConstructionFrame(Unit* unit)
|
|||
} else {
|
||||
unit->Frame = cframe->Frame;
|
||||
}
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -417,22 +416,17 @@ global void HandleActionBuilded(Unit* unit)
|
|||
|
||||
if (IsOnlySelected(unit)) {
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
} else if (unit->Player == ThisPlayer) {
|
||||
SelectedUnitChanged();
|
||||
}
|
||||
unit->CurrentSightRange = unit->Stats->SightRange;
|
||||
MapMarkUnitSight(unit);
|
||||
CheckUnitToBeDrawn(unit);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateConstructionFrame(unit);
|
||||
|
||||
unit->Wait = 1;
|
||||
if (IsOnlySelected(unit)) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
|
||||
//@}
|
||||
|
|
|
@ -209,13 +209,6 @@ local int ActionMoveGeneric(Unit* unit, const Animation* anim)
|
|||
unit->Wait >>= 1;
|
||||
}
|
||||
|
||||
//
|
||||
// Any graphic change?
|
||||
//
|
||||
if (!state || anim[state].Pixel || anim[state].Frame) {
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle the flags.
|
||||
//
|
||||
|
|
|
@ -150,13 +150,6 @@ local void RepairUnit(Unit* unit, Unit* goal)
|
|||
goal->HP = goal->Stats->HitPoints;
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckUnitToBeDrawn(goal)) {
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
if (IsOnlySelected(goal)) { // Update panel if unit is selected
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,8 +225,6 @@ global void HandleActionRepair(Unit* unit)
|
|||
UnitHeadingFromDeltaXY(unit,
|
||||
goal->X + (goal->Type->TileWidth - 1) / 2 - unit->X,
|
||||
goal->Y + (goal->Type->TileHeight - 1) / 2 - unit->Y);
|
||||
// FIXME: only if heading changes
|
||||
CheckUnitToBeDrawn(unit);
|
||||
} else if (err < 0) {
|
||||
if (goal) { // release reference
|
||||
RefsDecrease(goal);
|
||||
|
|
|
@ -79,9 +79,6 @@ global void HandleActionResearch(Unit* unit)
|
|||
unit->Reset = unit->Wait = 1;
|
||||
unit->Orders[0].Action = UnitActionStill;
|
||||
unit->SubAction = 0;
|
||||
if (IsOnlySelected(unit)) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -107,16 +104,10 @@ global void HandleActionResearch(Unit* unit)
|
|||
|
||||
// Upgrade can change all
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsOnlySelected(unit)) {
|
||||
// refresh info panel (to show progress, I think)
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
unit->Reset = 1;
|
||||
unit->Wait = CYCLES_PER_SECOND / 6;
|
||||
|
||||
|
|
|
@ -423,10 +423,6 @@ local int GatherResource(Unit* unit)
|
|||
DebugLevel3Fn("Harvested another %d resources.\n" _C_ addload);
|
||||
unit->Value += addload;
|
||||
source->Value -= addload;
|
||||
|
||||
if (IsOnlySelected(source)) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -546,11 +542,8 @@ local int StopGathering(Unit* unit)
|
|||
NewResetPath(unit);
|
||||
}
|
||||
|
||||
CheckUnitToBeDrawn(unit);
|
||||
if (IsOnlySelected(unit)) {
|
||||
SelectedUnitChanged();
|
||||
// FIXME: redundant?
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
}
|
||||
|
||||
unit->Wait = 1;
|
||||
|
@ -628,9 +621,6 @@ local int MoveToDepot(Unit* unit)
|
|||
unit->Player->TotalResources[resinfo->FinalResource] +=
|
||||
(unit->Value * unit->Player->Incomes[resinfo->FinalResource]) / 100;
|
||||
unit->Value = 0;
|
||||
if (unit->Player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources;
|
||||
}
|
||||
|
||||
unit->Wait = resinfo->WaitAtDepot / SpeedResourcesReturn[resinfo->ResourceId];
|
||||
if (!unit->Wait) {
|
||||
|
@ -697,7 +687,6 @@ local int WaitInDepot(Unit* unit)
|
|||
}
|
||||
}
|
||||
|
||||
CheckUnitToBeDrawn(unit);
|
||||
unit->Wait = 1;
|
||||
return unit->Orders[0].Action != UnitActionStill;
|
||||
}
|
||||
|
|
|
@ -248,12 +248,10 @@ global void ActionStillGeneric(Unit* unit, int ground)
|
|||
case 0: // Turn clockwise
|
||||
unit->Direction += NextDirection;
|
||||
UnitUpdateHeading(unit);
|
||||
CheckUnitToBeDrawn(unit);
|
||||
break;
|
||||
case 1: // Turn counter clockwise
|
||||
unit->Direction -= NextDirection;
|
||||
UnitUpdateHeading(unit);
|
||||
CheckUnitToBeDrawn(unit);
|
||||
break;
|
||||
default: // does nothing
|
||||
break;
|
||||
|
|
|
@ -212,16 +212,11 @@ global void HandleActionTrain(Unit* unit)
|
|||
|
||||
if (IsOnlySelected(unit)) {
|
||||
UpdateButtonPanel();
|
||||
MustRedraw |= RedrawPanels;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsOnlySelected(unit)) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
unit->Reset = 1;
|
||||
unit->Wait = CYCLES_PER_SECOND / 6;
|
||||
}
|
||||
|
|
|
@ -365,7 +365,6 @@ local void LeaveTransporter(Unit* unit)
|
|||
}
|
||||
if (IsOnlySelected(unit)) {
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
// We still have some units to unload, find a piece of free coast.
|
||||
|
|
|
@ -107,16 +107,11 @@ global void HandleActionUpgradeTo(Unit* unit)
|
|||
if (IsOnlySelected(unit) || player == ThisPlayer) {
|
||||
// could affect the buttons of any selected unit
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsOnlySelected(unit)) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
unit->Reset = 1;
|
||||
unit->Wait = CYCLES_PER_SECOND / 6;
|
||||
}
|
||||
|
|
|
@ -106,11 +106,6 @@ global int UnitShowAnimation(Unit* unit, const Animation* animation)
|
|||
unit->Wait >>= 1;
|
||||
}
|
||||
|
||||
// Anything changed the display?
|
||||
if ((animation[state].Frame || animation[state].Pixel)) {
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
|
||||
flags = animation[state].Flags;
|
||||
if (flags & AnimationReset) { // Reset can check for other actions
|
||||
unit->Reset = 1;
|
||||
|
@ -278,9 +273,6 @@ local void HandleRegenerations(Unit* unit)
|
|||
if (unit->Mana > unit->Type->_MaxMana) {
|
||||
unit->Mana = unit->Type->_MaxMana;
|
||||
}
|
||||
if (unit->Selected) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
|
||||
f = 0;
|
||||
|
@ -304,9 +296,6 @@ local void HandleRegenerations(Unit* unit)
|
|||
if (unit->HP > unit->Stats->HitPoints) {
|
||||
unit->HP = unit->Stats->HitPoints;
|
||||
}
|
||||
if (unit->Selected) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,7 +311,6 @@ local void HandleRegenerations(Unit* unit)
|
|||
local void HandleBuffs(Unit* unit, int amount)
|
||||
{
|
||||
int deadunit;
|
||||
int flag;
|
||||
|
||||
deadunit = 0;
|
||||
//
|
||||
|
@ -337,13 +325,8 @@ local void HandleBuffs(Unit* unit, int amount)
|
|||
if (unit->HP < 0) {
|
||||
LetUnitDie(unit);
|
||||
}
|
||||
if (unit->Selected) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
|
||||
// some frames delayed done my color cycling
|
||||
flag = 1;
|
||||
//
|
||||
// decrease spells effects time, if end redraw unit.
|
||||
//
|
||||
|
@ -353,9 +336,6 @@ local void HandleBuffs(Unit* unit, int amount)
|
|||
unit->Bloodlust -= amount;
|
||||
if (unit->Bloodlust < 0) {
|
||||
unit->Bloodlust = 0 ;
|
||||
if (!flag) {
|
||||
flag = CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Haste
|
||||
|
@ -363,9 +343,6 @@ local void HandleBuffs(Unit* unit, int amount)
|
|||
unit->Haste -= amount;
|
||||
if (unit->Haste < 0) {
|
||||
unit->Haste = 0;
|
||||
if (!flag) {
|
||||
flag = CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Slow
|
||||
|
@ -373,9 +350,6 @@ local void HandleBuffs(Unit* unit, int amount)
|
|||
unit->Slow -= amount;
|
||||
if (unit->Slow < 0) {
|
||||
unit->Slow = 0;
|
||||
if (!flag) {
|
||||
flag = CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Invisible
|
||||
|
@ -383,9 +357,6 @@ local void HandleBuffs(Unit* unit, int amount)
|
|||
unit->Invisible -= amount;
|
||||
if (unit->Invisible < 0) {
|
||||
unit->Invisible = 0;
|
||||
if (!flag) {
|
||||
flag = CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Unholy armor
|
||||
|
@ -393,9 +364,6 @@ local void HandleBuffs(Unit* unit, int amount)
|
|||
unit->UnholyArmor -= amount;
|
||||
if (unit->UnholyArmor < 0) {
|
||||
unit->UnholyArmor = 0;
|
||||
if (!flag) {
|
||||
flag = CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -467,7 +435,6 @@ local void HandleUnitAction(Unit* unit)
|
|||
|
||||
if (IsOnlySelected(unit)) { // update display for new action
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -910,13 +910,6 @@ global void CommandTrainUnit(Unit* unit, UnitType* type,
|
|||
unit->Orders[1].Goal = NoUnitP;
|
||||
unit->Orders[1].Arg1 = NULL;
|
||||
} else {
|
||||
//
|
||||
// Update interface.
|
||||
//
|
||||
if (unit->Player == ThisPlayer && unit->Selected) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
//
|
||||
// Training slots are all already full. (NETWORK!)
|
||||
//
|
||||
|
@ -995,7 +988,6 @@ global void CommandCancelTraining(Unit* unit, int slot, const UnitType* type)
|
|||
//
|
||||
if (unit->Player == ThisPlayer && unit->Selected) {
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1072,7 +1064,6 @@ global void CommandCancelUpgradeTo(Unit* unit)
|
|||
//
|
||||
if (unit->Player == ThisPlayer && unit->Selected) {
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
unit->Wait = unit->Reset = 1; // immediately start next command.
|
||||
|
@ -1168,7 +1159,6 @@ global void CommandCancelResearch(Unit* unit)
|
|||
//
|
||||
if (unit->Player == ThisPlayer && unit->Selected) {
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
unit->Wait = unit->Reset = 1; // immediately start next command.
|
||||
|
|
|
@ -924,8 +924,6 @@ global void EditorUpdateDisplay(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
HideAnyCursor(); // remove cursor (when available)
|
||||
|
||||
DrawMapArea(); // draw the map area
|
||||
|
||||
if (CursorOn == CursorOnMap) {
|
||||
|
@ -1017,7 +1015,7 @@ global void EditorUpdateDisplay(void)
|
|||
// FIXME: For now update everything each frame
|
||||
|
||||
// refresh entire screen, so no further invalidate needed
|
||||
InvalidateAreaAndCheckCursor(0, 0, VideoWidth, VideoHeight);
|
||||
Invalidate();
|
||||
RealizeVideoMemory();
|
||||
}
|
||||
|
||||
|
@ -1257,7 +1255,6 @@ local void EditorCallbackButtonDown(unsigned button __attribute__ ((unused)))
|
|||
if ((MouseButtons & LeftButton) && TheUI.SelectedViewport != vp) {
|
||||
// viewport changed
|
||||
TheUI.SelectedViewport = vp;
|
||||
MustRedraw = RedrawMinimapCursor | RedrawMap;
|
||||
}
|
||||
|
||||
if (MouseButtons & LeftButton) {
|
||||
|
@ -1291,7 +1288,6 @@ local void EditorCallbackButtonDown(unsigned button __attribute__ ((unused)))
|
|||
CursorStartY = CursorY;
|
||||
GameCursor = TheUI.Scroll.Cursor;
|
||||
DebugLevel3("Cursor middle down %d,%d\n" _C_ CursorX _C_ CursorY);
|
||||
MustRedraw |= RedrawCursor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1771,7 +1767,6 @@ local void EditorCallbackMouse(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaMenu;
|
||||
ButtonUnderCursor = ButtonUnderMenu;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1799,7 +1794,6 @@ local void EditorCallbackMouse(int x, int y)
|
|||
TheUI.MouseViewport = vp;
|
||||
DebugLevel0Fn("active viewport changed to %d.\n" _C_
|
||||
TheUI.Viewports - vp);
|
||||
MustRedraw = RedrawMinimapCursor | RedrawMap;
|
||||
}
|
||||
CursorOn = CursorOnMap;
|
||||
|
||||
|
@ -1975,7 +1969,6 @@ local void CreateEditor(void)
|
|||
UpdateMinimap();
|
||||
|
||||
if (1) {
|
||||
DestroyCursorBackground();
|
||||
ProcessMenu("menu-editor-tips", 1);
|
||||
InterfaceState = IfaceStateNormal;
|
||||
}
|
||||
|
@ -2009,11 +2002,9 @@ global int EditorSavePud(const char* file)
|
|||
}
|
||||
if (SavePud(file, &TheMap) == -1) {
|
||||
ErrorMenu("Cannot save map");
|
||||
MustRedraw = RedrawEverything;
|
||||
InterfaceState = IfaceStateNormal;
|
||||
EditorUpdateDisplay();
|
||||
InterfaceState = IfaceStateMenu;
|
||||
MustRedraw = RedrawMenu;
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < NumUnits; ++i) {
|
||||
|
@ -2071,14 +2062,9 @@ global void EditorMainLoop(void)
|
|||
while (EditorRunning) {
|
||||
PlayListAdvance();
|
||||
|
||||
if (MustRedraw & RedrawMinimap) {
|
||||
UpdateMinimap();
|
||||
}
|
||||
UpdateMinimap();
|
||||
|
||||
if (MustRedraw) {
|
||||
EditorUpdateDisplay();
|
||||
MustRedraw = 0;
|
||||
}
|
||||
EditorUpdateDisplay();
|
||||
|
||||
//
|
||||
// Map scrolling
|
||||
|
|
|
@ -545,7 +545,6 @@ global void CreateGame(char* filename, WorldMap* map)
|
|||
GameResult = GameNoResult;
|
||||
|
||||
CommandLog(NULL, NoUnitP, FlushCommands, -1, -1, NoUnitP, NULL, -1);
|
||||
DestroyCursorBackground();
|
||||
VideoClearScreen();
|
||||
}
|
||||
|
||||
|
|
|
@ -251,6 +251,7 @@ local void SplitTextIntoLines(const char* text, int w, TextLines** lines)
|
|||
while (s1) {
|
||||
char* x1;
|
||||
char* x2;
|
||||
|
||||
if ((s1 = strpbrk(s1, "\n\r"))) {
|
||||
if ((s1[0] == '\n' && s1[1] == '\r') ||
|
||||
(s1[0] == '\r' && s1[1] == '\n')) {
|
||||
|
@ -398,7 +399,6 @@ global void ShowIntro(const Intro* intro)
|
|||
UseContinueButton = 1;
|
||||
InitContinueButton(455 * VideoWidth / 640, 440 * VideoHeight / 480);
|
||||
GameCursor = TheUI.Point.Cursor;
|
||||
DestroyCursorBackground();
|
||||
|
||||
VideoClearScreen();
|
||||
|
||||
|
@ -477,7 +477,6 @@ global void ShowIntro(const Intro* intro)
|
|||
}
|
||||
}
|
||||
|
||||
HideAnyCursor();
|
||||
//
|
||||
// Draw background
|
||||
//
|
||||
|
@ -518,15 +517,7 @@ global void ShowIntro(const Intro* intro)
|
|||
DrawContinueButton();
|
||||
DrawAnyCursor();
|
||||
|
||||
if (!line && !c) {
|
||||
Invalidate();
|
||||
} else {
|
||||
InvalidateAreaAndCheckCursor(70 * VideoWidth / 640, 80 * VideoHeight / 480,
|
||||
70 * VideoWidth / 640 + 320 + 1, 170 * VideoHeight / 480 + 1);
|
||||
InvalidateAreaAndCheckCursor(ContinueButtonX, ContinueButtonY,
|
||||
106, 27);
|
||||
InvalidateCursorAreas();
|
||||
}
|
||||
Invalidate();
|
||||
RealizeVideoMemory();
|
||||
|
||||
if (!IntroNoEvent) {
|
||||
|
@ -610,7 +601,6 @@ global void ShowCredits(Credits* credits)
|
|||
UseContinueButton = 1;
|
||||
InitContinueButton(TheUI.Offset640X + 455, TheUI.Offset480Y + 440);
|
||||
GameCursor = TheUI.Point.Cursor;
|
||||
DestroyCursorBackground();
|
||||
|
||||
x = TheUI.Offset640X;
|
||||
y = TheUI.Offset480Y;
|
||||
|
@ -618,9 +608,6 @@ global void ShowCredits(Credits* credits)
|
|||
line = 0;
|
||||
scrolling = 1;
|
||||
while (1) {
|
||||
|
||||
HideAnyCursor();
|
||||
|
||||
//
|
||||
// Draw background
|
||||
//
|
||||
|
@ -669,7 +656,6 @@ global void ShowCredits(Credits* credits)
|
|||
}
|
||||
|
||||
VideoClearScreen();
|
||||
DestroyCursorBackground();
|
||||
|
||||
VideoSyncSpeed = old_video_sync;
|
||||
SetVideoSync();
|
||||
|
@ -868,27 +854,9 @@ local int GameStatsDrawFunc(int frame)
|
|||
int description_offset;
|
||||
int percent;
|
||||
int max;
|
||||
int draw_all;
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
draw_all = 1;
|
||||
#else
|
||||
draw_all = 0;
|
||||
#endif
|
||||
|
||||
#ifndef USE_OPENGL
|
||||
// If a button was pressed draw everything
|
||||
if (IntroButtonPressed) {
|
||||
draw_all = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
done = 0;
|
||||
|
||||
if (!draw_all && (frame % stats_pause) != 0) {
|
||||
return done;
|
||||
}
|
||||
|
||||
percent = 100;
|
||||
x = TheUI.Offset640X;
|
||||
y = TheUI.Offset480Y;
|
||||
|
@ -915,12 +883,12 @@ local int GameStatsDrawFunc(int frame)
|
|||
}
|
||||
line_spacing = (432 - bottom_offset - description_offset) / c;
|
||||
|
||||
if (!draw_all || (dodraw <= 10 && (frame % stats_pause) == 0)) {
|
||||
if (dodraw <= 10 && (frame % stats_pause) == 0) {
|
||||
PlayGameSound(SoundIdForName("statsthump"), MaxSampleVolume);
|
||||
}
|
||||
|
||||
|
||||
if (dodraw==1 || (draw_all && dodraw >= 1)) {
|
||||
if (dodraw >= 1) {
|
||||
char* outcome;
|
||||
|
||||
VideoDrawTextCentered(x + 106, y + top_offset, LargeFont, "Outcome");
|
||||
|
@ -933,7 +901,7 @@ local int GameStatsDrawFunc(int frame)
|
|||
outcome);
|
||||
}
|
||||
|
||||
if (dodraw == 2 || (draw_all && dodraw >= 2)) {
|
||||
if (dodraw >= 2) {
|
||||
char* rank;
|
||||
char** ranks;
|
||||
int* scores;
|
||||
|
@ -963,13 +931,13 @@ local int GameStatsDrawFunc(int frame)
|
|||
VideoDrawTextCentered(x + 324, y + top_offset + 21, SmallTitleFont, rank);
|
||||
}
|
||||
|
||||
if (dodraw == 3 || (draw_all && dodraw >= 3)) {
|
||||
if (dodraw >= 3) {
|
||||
VideoDrawTextCentered(x + 540, y + top_offset, LargeFont, "Score");
|
||||
sprintf(buf, "%u", ThisPlayer->Score);
|
||||
VideoDrawTextCentered(x + 540, y + top_offset + 21, SmallTitleFont, buf);
|
||||
}
|
||||
|
||||
if (dodraw == 4 || (draw_all && dodraw >= 4)) {
|
||||
if (dodraw >= 4) {
|
||||
max = Players[0].TotalUnits;
|
||||
for (i = 1; i < PlayerMax - 1; ++i) {
|
||||
p = &Players[i];
|
||||
|
@ -1014,7 +982,7 @@ local int GameStatsDrawFunc(int frame)
|
|||
}
|
||||
}
|
||||
|
||||
if (dodraw == 5 || (draw_all && dodraw >= 5)) {
|
||||
if (dodraw >= 5) {
|
||||
max = Players[0].TotalBuildings;
|
||||
for (i = 1; i < PlayerMax - 1; ++i) {
|
||||
p = &Players[i];
|
||||
|
@ -1047,7 +1015,7 @@ local int GameStatsDrawFunc(int frame)
|
|||
}
|
||||
}
|
||||
|
||||
if (dodraw == 6 || (draw_all && dodraw >= 6)) {
|
||||
if (dodraw >= 6) {
|
||||
max = Players[0].TotalResources[GoldCost];
|
||||
for (i = 1; i < PlayerMax - 1; ++i) {
|
||||
p = &Players[i];
|
||||
|
@ -1080,7 +1048,7 @@ local int GameStatsDrawFunc(int frame)
|
|||
}
|
||||
}
|
||||
|
||||
if (dodraw == 7 || (draw_all && dodraw >= 7)) {
|
||||
if (dodraw >= 7) {
|
||||
max = Players[0].TotalResources[WoodCost];
|
||||
for (i = 1; i < PlayerMax - 1; ++i) {
|
||||
p = &Players[i];
|
||||
|
@ -1113,7 +1081,7 @@ local int GameStatsDrawFunc(int frame)
|
|||
}
|
||||
}
|
||||
|
||||
if (dodraw == 8 || (draw_all && dodraw >= 8)) {
|
||||
if (dodraw >= 8) {
|
||||
max = Players[0].TotalResources[OilCost];
|
||||
for (i = 1; i < PlayerMax - 1; ++i) {
|
||||
p = &Players[i];
|
||||
|
@ -1146,7 +1114,7 @@ local int GameStatsDrawFunc(int frame)
|
|||
}
|
||||
}
|
||||
|
||||
if (dodraw == 9 || (draw_all && dodraw >= 9)) {
|
||||
if (dodraw >= 9) {
|
||||
max = Players[0].TotalKills;
|
||||
for (i = 1; i < PlayerMax - 1; ++i) {
|
||||
p = &Players[i];
|
||||
|
@ -1179,7 +1147,7 @@ local int GameStatsDrawFunc(int frame)
|
|||
}
|
||||
}
|
||||
|
||||
if (dodraw == 10 || (draw_all && dodraw >= 10)) {
|
||||
if (dodraw >= 10) {
|
||||
max = Players[0].TotalRazings;
|
||||
for (i = 1; i < PlayerMax - 1; ++i) {
|
||||
p = &Players[i];
|
||||
|
@ -1257,23 +1225,12 @@ global void ShowStats(void)
|
|||
UseContinueButton = 1;
|
||||
InitContinueButton(TheUI.Offset640X + 455, TheUI.Offset480Y + 440);
|
||||
GameCursor = TheUI.Point.Cursor;
|
||||
DestroyCursorBackground();
|
||||
|
||||
frame = 1;
|
||||
done = 0;
|
||||
IntroNoEvent = 1;
|
||||
IntroButtonPressed = 0;
|
||||
#ifndef USE_OPENGL
|
||||
if (background) {
|
||||
VideoDrawSubClip(background, 0, 0,
|
||||
background->Width, background->Height,
|
||||
(VideoWidth - background->Width) / 2,
|
||||
(VideoHeight - background->Height) / 2);
|
||||
}
|
||||
#endif
|
||||
while (1) {
|
||||
HideAnyCursor();
|
||||
#ifdef USE_OPENGL
|
||||
if (background) {
|
||||
VideoDrawSubClip(background, 0, 0,
|
||||
background->Width, background->Height,
|
||||
|
@ -1281,11 +1238,6 @@ global void ShowStats(void)
|
|||
(VideoHeight - background->Height) / 2);
|
||||
}
|
||||
GameStatsDrawFunc(frame);
|
||||
#else
|
||||
if (!done) {
|
||||
done = GameStatsDrawFunc(frame);
|
||||
}
|
||||
#endif
|
||||
DrawContinueButton();
|
||||
DrawAnyCursor();
|
||||
|
||||
|
|
|
@ -243,7 +243,6 @@ global void LoadGame(char* filename)
|
|||
SyncRandSeed = syncrand;
|
||||
SyncHash = synchash;
|
||||
SelectionChanged();
|
||||
MustRedraw = RedrawEverything;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -202,32 +202,13 @@ extern CursorType* CursorTypeByIdent(const char* ident);
|
|||
|
||||
/// Draw any cursor
|
||||
extern void DrawAnyCursor(void);
|
||||
/// Hide any cursor
|
||||
extern void HideAnyCursor(void);
|
||||
/// Animate the cursor
|
||||
extern void CursorAnimate(unsigned ticks);
|
||||
|
||||
/// Save/load rectangle region from/to screen
|
||||
/// Note: this is made extern for minimap only
|
||||
#ifndef USE_OPENGL
|
||||
extern void SaveCursorRectangle(void *buffer, int x, int y, int w, int h);
|
||||
extern void LoadCursorRectangle(void *buffer, int x, int y, int w, int h);
|
||||
#else
|
||||
#define SaveCursorRectangle(buffer, x, y, w, h)
|
||||
#define LoadCursorRectangle(buffer, x, y, w, h)
|
||||
#endif
|
||||
|
||||
/// Invalidate given area and check if cursor won't need any
|
||||
extern void InvalidateAreaAndCheckCursor(int x, int y, int w, int h);
|
||||
/// Invalidate (remaining) cursor areas
|
||||
extern void InvalidateCursorAreas(void);
|
||||
|
||||
/// Initialize the cursor module
|
||||
extern void InitVideoCursors(void);
|
||||
/// Cleanup the cursor module
|
||||
extern void CleanCursors(void);
|
||||
/// Destroy image behind cursor.
|
||||
extern void DestroyCursorBackground(void);
|
||||
|
||||
//@}
|
||||
|
||||
|
|
|
@ -341,16 +341,10 @@ extern void DrawMapBackgroundInViewport(const Viewport*, int x, int y);
|
|||
/// Build tables for map
|
||||
extern void InitMap(void);
|
||||
|
||||
/// Mark position inside screenmap be drawn for next display update
|
||||
extern int MarkDrawPosMap(int x, int y );
|
||||
/// Denote wether area in map is overlapping with viewport on screen
|
||||
extern int MapAreaVisibleInViewport(const Viewport*, int , int , int , int);
|
||||
/// Check if any part of an area is visible in viewport
|
||||
extern int AnyMapAreaVisibleInViewport(const Viewport*, int , int , int , int);
|
||||
/// Set overlapping area as entries in MustRedrawRow and MustRedrawTile
|
||||
extern int MarkDrawAreaMap(int sx, int sy, int ex, int ey);
|
||||
/// Set all entries in MustRedrawRow and MustRedrawTile
|
||||
extern void MarkDrawEntireMap(void);
|
||||
|
||||
//
|
||||
// in map_fog.c
|
||||
|
|
|
@ -360,9 +360,6 @@ extern void EndMenu(void);
|
|||
/// Find a menu by id
|
||||
extern Menu *FindMenu(const char *MenuId);
|
||||
|
||||
/// Invalidate previously redrawn menu areas
|
||||
extern void InvalidateMenuAreas(void);
|
||||
|
||||
/// The scenario path received from server, Update the client menu
|
||||
extern int NetClientSelectScenario(void);
|
||||
/// State info received from server, Update the client menu.
|
||||
|
|
|
@ -74,8 +74,6 @@ extern void CreateMinimap(void);
|
|||
extern void DestroyMinimap(void);
|
||||
/// Draw minimap with viewpoint
|
||||
extern void DrawMinimap(int vx, int vy);
|
||||
/// Hide minimap cursor
|
||||
extern void HideMinimapCursor(void);
|
||||
/// Draw minimap viewpoint cursor
|
||||
extern void DrawMinimapCursor(int vx, int vy);
|
||||
|
||||
|
|
|
@ -515,8 +515,6 @@ extern Missile* MakeMissile(MissileType*, int, int, int, int);
|
|||
extern Missile* MakeLocalMissile(MissileType*, int, int, int, int);
|
||||
/// fire a missile
|
||||
extern void FireMissile(Unit*);
|
||||
/// check if missile should be drawn
|
||||
extern int CheckMissileToBeDrawn(const Missile* missile);
|
||||
|
||||
/// Draw all missiles
|
||||
extern void DrawMissile(MissileType* mtype, int frame, int x, int y);
|
||||
|
|
|
@ -802,8 +802,6 @@ extern int UnitVisibleOnMinimap(const Unit* unit);
|
|||
/// Returns true if unit is visible in an viewport. Only for ThisPlayer.
|
||||
extern int UnitVisibleInViewport(const Unit* unit, const Viewport* vp);
|
||||
|
||||
/// To be called when the look of the unit changes.
|
||||
extern int CheckUnitToBeDrawn(Unit* unit);
|
||||
/// @todo more docu
|
||||
extern void GetUnitMapArea(const Unit* unit, int *sx, int *sy,
|
||||
int *ex, int *ey);
|
||||
|
|
|
@ -79,8 +79,6 @@ global void MapMarkSeenTile(int x, int y)
|
|||
// Nothing changed? Seeing already the correct tile.
|
||||
//
|
||||
if ((tile = mf->Tile) == (seentile = mf->SeenTile)) {
|
||||
// FIXME: Check bounds
|
||||
MarkDrawAreaMap(x - 1, y - 1, x + 1, y + 1);
|
||||
return;
|
||||
}
|
||||
mf->SeenTile = tile;
|
||||
|
@ -210,7 +208,6 @@ global void ViewportSetViewpoint(Viewport* vp, int x, int y, int offsetx, int of
|
|||
vp->MapWidth = ((vp->EndX - vp->X) + vp->OffsetX - 1) / TileSizeX + 1;
|
||||
vp->MapHeight = ((vp->EndY - vp->Y) + vp->OffsetY - 1) / TileSizeY + 1;
|
||||
|
||||
MarkDrawEntireMap();
|
||||
MustRedraw |= RedrawMinimap | RedrawMinimapCursor;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,33 +169,6 @@ global void MapDrawTile(int tile, int x, int y)
|
|||
-- Global functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
** Mark position inside viewport be drawn for next display update.
|
||||
**
|
||||
** @param x X map tile position of point in Map to be marked.
|
||||
** @param y Y map tile position of point in Map to be marked.
|
||||
**
|
||||
** @return True if inside and marked, false otherwise.
|
||||
**
|
||||
** @note latimerius: MarkDrawPosMap() in split screen environment
|
||||
** schedules RedrawMap if (x,y) is visible inside *any* of the existing
|
||||
** viewports. Is this OK, johns? Do you think it would pay having
|
||||
** RedrawViewport0, RedrawViewport1 etc. variables and redraw just
|
||||
** vp's that actually need redrawing? We should evaluate this.
|
||||
** JOHNS: A complete viewport redraw is still too much work. The final
|
||||
** version should only redraw the needed tiles.
|
||||
*/
|
||||
global int MarkDrawPosMap(int x, int y)
|
||||
{
|
||||
Viewport* vp;
|
||||
|
||||
if ((vp = MapTileGetViewport(x, y))) {
|
||||
MustRedraw |= RedrawMap;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Denote wether area in map is overlapping with the viewport.
|
||||
**
|
||||
|
@ -251,37 +224,6 @@ global int AnyMapAreaVisibleInViewport(const Viewport* vp, int sx, int sy,
|
|||
PointInViewport(vp, ex, sy) || PointInViewport(vp, ex, ey);
|
||||
}
|
||||
|
||||
/**
|
||||
** Mark overlapping area with viewport be drawn for next display update.
|
||||
**
|
||||
** @param sx X map tile position of area in Map to be marked.
|
||||
** @param sy Y map tile position of area in Map to be marked.
|
||||
** @param ex X map tile position of area in Map to be marked.
|
||||
** @param ey Y map tile position of area in Map to be marked.
|
||||
**
|
||||
** @return True if overlapping and marked, false otherwise.
|
||||
**
|
||||
** @see MustRedrawRow @see MustRedrawTile.
|
||||
*/
|
||||
global int MarkDrawAreaMap(int sx, int sy, int ex, int ey)
|
||||
{
|
||||
if (MapTileGetViewport(sx, sy) || MapTileGetViewport(ex, ey) ||
|
||||
MapTileGetViewport(sx, ey) || MapTileGetViewport(ex, sy)) {
|
||||
MustRedraw |= RedrawMap;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Enable entire map be drawn for next display update.
|
||||
*/
|
||||
global void MarkDrawEntireMap(void)
|
||||
{
|
||||
DebugLevel3Fn("\n");
|
||||
MustRedraw |= RedrawMap;
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw the map backgrounds.
|
||||
**
|
||||
|
|
|
@ -448,7 +448,6 @@ global void UpdateFogOfWarChange(void)
|
|||
for (x = 0; x < NumUnits; ++x) {
|
||||
UnitCountSeen(Units[x]);
|
||||
}
|
||||
MarkDrawEntireMap();
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
|
|
@ -178,7 +178,6 @@ global void MapFixSeenRockTile(int x, int y)
|
|||
// FIXME: can this only happen if seen?
|
||||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +317,6 @@ global void MapFixRockTile(int x, int y)
|
|||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MapMarkSeenTile(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
}
|
||||
|
@ -346,7 +344,6 @@ global void MapRemoveRock(unsigned x, unsigned y)
|
|||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MapMarkSeenTile(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
#ifdef MAP_REGIONS
|
||||
|
|
|
@ -165,7 +165,6 @@ global void MapFixSeenWallTile(int x, int y)
|
|||
// FIXME: can this only happen if seen?
|
||||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +265,6 @@ global void MapFixWallTile(int x, int y)
|
|||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MapMarkSeenTile(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +305,6 @@ global void MapRemoveWall(unsigned x, unsigned y)
|
|||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MapMarkSeenTile(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
#ifdef MAP_REGIONS
|
||||
|
@ -350,7 +347,6 @@ global void MapSetWall(unsigned x, unsigned y, int humanwall)
|
|||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MapMarkSeenTile(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
#ifdef MAP_REGIONS
|
||||
|
|
|
@ -176,7 +176,6 @@ global void MapFixSeenWoodTile(int x, int y)
|
|||
// FIXME: can this only happen if seen?
|
||||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +313,6 @@ global void MapFixWoodTile(int x, int y)
|
|||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MapMarkSeenTile(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +341,6 @@ global void MapRemoveWood(unsigned x, unsigned y)
|
|||
if (IsMapFieldVisible(ThisPlayer, x, y)) {
|
||||
UpdateMinimapSeenXY(x, y);
|
||||
MapMarkSeenTile(x, y);
|
||||
MarkDrawPosMap(x, y);
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
#ifdef MAP_REGIONS
|
||||
|
|
|
@ -620,19 +620,6 @@ global void DestroyMinimap(void)
|
|||
Minimap2MapY = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
** Hide minimap cursor.
|
||||
*/
|
||||
global void HideMinimapCursor(void)
|
||||
{
|
||||
if (OldMinimapCursorW) {
|
||||
LoadCursorRectangle(OldMinimapCursorImage,
|
||||
OldMinimapCursorX, OldMinimapCursorY,
|
||||
OldMinimapCursorW, OldMinimapCursorH);
|
||||
OldMinimapCursorW = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw minimap cursor.
|
||||
**
|
||||
|
@ -648,28 +635,13 @@ global void DrawMinimapCursor(int vx, int vy)
|
|||
int i;
|
||||
|
||||
// Determine and save region below minimap cursor
|
||||
OldMinimapCursorX = x =
|
||||
TheUI.MinimapPosX + MinimapX + (vx * MinimapScaleX) / MINIMAP_FAC;
|
||||
OldMinimapCursorY = y =
|
||||
TheUI.MinimapPosY + MinimapY + (vy * MinimapScaleY) / MINIMAP_FAC;
|
||||
OldMinimapCursorW = w =
|
||||
(TheUI.SelectedViewport->MapWidth * MinimapScaleX) / MINIMAP_FAC;
|
||||
OldMinimapCursorH = h =
|
||||
(TheUI.SelectedViewport->MapHeight * MinimapScaleY) / MINIMAP_FAC;
|
||||
x = TheUI.MinimapPosX + MinimapX + (vx * MinimapScaleX) / MINIMAP_FAC;
|
||||
y = TheUI.MinimapPosY + MinimapY + (vy * MinimapScaleY) / MINIMAP_FAC;
|
||||
w = (TheUI.SelectedViewport->MapWidth * MinimapScaleX) / MINIMAP_FAC;
|
||||
h = (TheUI.SelectedViewport->MapHeight * MinimapScaleY) / MINIMAP_FAC;
|
||||
|
||||
i = (w + 1 + h) * 2 * TheScreen->format->BytesPerPixel;
|
||||
|
||||
if (OldMinimapCursorSize < i) {
|
||||
if (OldMinimapCursorImage) {
|
||||
OldMinimapCursorImage = realloc(OldMinimapCursorImage, i);
|
||||
} else {
|
||||
OldMinimapCursorImage = malloc(i);
|
||||
}
|
||||
DebugLevel3("Cursor memory %d\n" _C_ i);
|
||||
OldMinimapCursorSize = i;
|
||||
}
|
||||
SaveCursorRectangle(OldMinimapCursorImage, x, y, w, h);
|
||||
|
||||
// Draw cursor as rectangle (Note: unclipped, as it is always visible)
|
||||
VideoDrawTransRectangle(TheUI.ViewportCursorColor, x, y, w, h, 128);
|
||||
}
|
||||
|
|
|
@ -227,7 +227,6 @@ static int FlacStreamRead(Sample *sample, void *buf, int len)
|
|||
}
|
||||
|
||||
memcpy(buf, sample->Buffer + sample->Pos, len);
|
||||
|
||||
sample->Pos += len;
|
||||
sample->Len -= len;
|
||||
|
||||
|
|
|
@ -160,8 +160,6 @@ global void DoScrollArea(enum _scroll_state_ state, int fast)
|
|||
|
||||
// This recalulates some values
|
||||
HandleMouseMove(CursorX, CursorY);
|
||||
MarkDrawEntireMap();
|
||||
MustRedraw |= RedrawMinimap | RedrawCursors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,11 +279,6 @@ local void DrawMapViewport(Viewport* vp)
|
|||
}
|
||||
SetClipping(0, 0, VideoWidth - 1, VideoHeight - 1);
|
||||
}
|
||||
|
||||
// Resources over map
|
||||
if (TheUI.ResourceX == -1 || TheUI.ResourceY == -1) {
|
||||
MustRedraw |= RedrawResources;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,60 +327,27 @@ global void DrawMapArea(void)
|
|||
}
|
||||
|
||||
/**
|
||||
** Display update.
|
||||
** Display update.
|
||||
**
|
||||
* This functions updates everything on screen. The map, the gui, the
|
||||
** cursors.
|
||||
** This functions updates everything on screen. The map, the gui, the
|
||||
** cursors.
|
||||
*/
|
||||
global void UpdateDisplay(void)
|
||||
{
|
||||
MustRedraw &= EnableRedraw; // Don't redraw disabled parts
|
||||
|
||||
HideAnyCursor(); // remove cursor (when available)
|
||||
|
||||
if (MustRedraw & RedrawMap) {
|
||||
DrawMapArea();
|
||||
|
||||
//
|
||||
// Force Redraw Items that are on top of map, they don't have a panel
|
||||
//
|
||||
if (!TheUI.MinimapPanel.Graphic) {
|
||||
MustRedraw |= RedrawMinimapBorder;
|
||||
MustRedraw |= RedrawMinimap;
|
||||
}
|
||||
if (!TheUI.InfoPanel.Graphic) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
if (!TheUI.ButtonPanel.Graphic) {
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
}
|
||||
if (!TheUI.Resource.Graphic) {
|
||||
MustRedraw |= RedrawResources;
|
||||
}
|
||||
if (!TheUI.StatusLine.Graphic) {
|
||||
MustRedraw |= RedrawStatusLine;
|
||||
}
|
||||
}
|
||||
|
||||
if (MustRedraw & (RedrawMessage | RedrawMap)) {
|
||||
DrawMessages();
|
||||
}
|
||||
|
||||
if (MustRedraw & RedrawFillers) {
|
||||
if (EnableRedraw != RedrawMenu) {
|
||||
int i;
|
||||
|
||||
DrawMapArea();
|
||||
DrawMessages();
|
||||
|
||||
for (i = 0; i < TheUI.NumFillers; ++i) {
|
||||
VideoDrawSubClip(TheUI.Filler[i].Graphic, 0, 0,
|
||||
TheUI.Filler[i].Graphic->Width,
|
||||
TheUI.Filler[i].Graphic->Height,
|
||||
TheUI.FillerX[i], TheUI.FillerY[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (MustRedraw & RedrawMenuButton) {
|
||||
DrawMenuButtonArea();
|
||||
}
|
||||
if (MustRedraw & RedrawMinimapBorder) {
|
||||
|
||||
if (TheUI.MinimapPanel.Graphic) {
|
||||
VideoDrawSubClip(TheUI.MinimapPanel.Graphic, 0, 0,
|
||||
TheUI.MinimapPanel.Graphic->Width,
|
||||
|
@ -398,153 +358,29 @@ global void UpdateDisplay(void)
|
|||
TheUI.MinimapPosX - 1, TheUI.MinimapPosY - 1,
|
||||
TheUI.MinimapW + 2, TheUI.MinimapH + 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (MustRedraw & RedrawMinimap) {
|
||||
// FIXME: redraw only 1* per second!
|
||||
// HELPME: Viewpoint rectangle must be drawn faster (if implemented) ?
|
||||
DrawMinimap(TheUI.SelectedViewport->MapX, TheUI.SelectedViewport->MapY);
|
||||
DrawMinimapCursor(TheUI.SelectedViewport->MapX,
|
||||
TheUI.SelectedViewport->MapY);
|
||||
} else if (MustRedraw & RedrawMinimapCursor) {
|
||||
HideMinimapCursor();
|
||||
DrawMinimapCursor(TheUI.SelectedViewport->MapX,
|
||||
TheUI.SelectedViewport->MapY);
|
||||
}
|
||||
|
||||
if (MustRedraw & RedrawInfoPanel) {
|
||||
DrawInfoPanel();
|
||||
}
|
||||
if (MustRedraw & RedrawButtonPanel) {
|
||||
DrawButtonPanel();
|
||||
}
|
||||
if (MustRedraw & RedrawResources) {
|
||||
DrawResources();
|
||||
}
|
||||
if (MustRedraw & RedrawStatusLine) {
|
||||
DrawStatusLine();
|
||||
MustRedraw |= RedrawCosts;
|
||||
}
|
||||
if (MustRedraw & RedrawCosts) {
|
||||
DrawCosts();
|
||||
}
|
||||
if (MustRedraw & RedrawTimer) {
|
||||
DrawTimer();
|
||||
}
|
||||
|
||||
if (MustRedraw & RedrawMenu) {
|
||||
DrawMenu(CurrentMenu);
|
||||
}
|
||||
DrawMenu(CurrentMenu);
|
||||
|
||||
DrawAnyCursor();
|
||||
|
||||
//
|
||||
// Update changes to display.
|
||||
//
|
||||
if (MustRedraw & RedrawAll) {
|
||||
// refresh entire screen, so no further invalidate needed
|
||||
InvalidateAreaAndCheckCursor(0, 0, VideoWidth, VideoHeight);
|
||||
} else {
|
||||
if (MustRedraw & RedrawMap) {
|
||||
// FIXME: split into small parts see RedrawTile and RedrawRow
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.MapArea.X, TheUI.MapArea.Y,
|
||||
TheUI.MapArea.EndX - TheUI.MapArea.X + 1,
|
||||
TheUI.MapArea.EndY - TheUI.MapArea.Y + 1);
|
||||
}
|
||||
if (MustRedraw & RedrawFillers) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < TheUI.NumFillers; ++i) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.FillerX[i], TheUI.FillerY[i],
|
||||
TheUI.Filler[i].Graphic->Width,
|
||||
TheUI.Filler[i].Graphic->Height);
|
||||
}
|
||||
}
|
||||
if (MustRedraw & RedrawMenuButton) {
|
||||
if (!IsNetworkGame()) {
|
||||
if (TheUI.MenuButton.X != -1) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.MenuButton.X, TheUI.MenuButton.Y,
|
||||
TheUI.MenuButton.Width,
|
||||
TheUI.MenuButton.Height);
|
||||
}
|
||||
} else {
|
||||
if (TheUI.NetworkMenuButton.X != -1) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.NetworkMenuButton.X,
|
||||
TheUI.NetworkMenuButton.Y,
|
||||
TheUI.NetworkMenuButton.Width,
|
||||
TheUI.NetworkMenuButton.Height);
|
||||
}
|
||||
if (TheUI.NetworkDiplomacyButton.X != -1) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.NetworkDiplomacyButton.X,
|
||||
TheUI.NetworkDiplomacyButton.Y,
|
||||
TheUI.NetworkDiplomacyButton.Width,
|
||||
TheUI.NetworkDiplomacyButton.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (MustRedraw & RedrawMinimapBorder) {
|
||||
if (TheUI.MinimapPanel.Graphic) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.MinimapPanelX, TheUI.MinimapPanelY,
|
||||
TheUI.MinimapPanel.Graphic->Width,
|
||||
TheUI.MinimapPanel.Graphic->Height);
|
||||
}
|
||||
} else if ((MustRedraw & RedrawMinimap) ||
|
||||
(MustRedraw & RedrawMinimapCursor)) {
|
||||
// FIXME: Redraws too much of the minimap
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.MinimapPosX, TheUI.MinimapPosY,
|
||||
TheUI.MinimapW, TheUI.MinimapH);
|
||||
}
|
||||
if (MustRedraw & RedrawInfoPanel) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.InfoPanelX, TheUI.InfoPanelY,
|
||||
TheUI.InfoPanelW, TheUI.InfoPanelH);
|
||||
}
|
||||
if ((MustRedraw & RedrawButtonPanel) && TheUI.ButtonPanel.Graphic) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.ButtonPanelX, TheUI.ButtonPanelY,
|
||||
TheUI.ButtonPanel.Graphic->Width,
|
||||
TheUI.ButtonPanel.Graphic->Height);
|
||||
}
|
||||
if (MustRedraw&RedrawResources && TheUI.Resource.Graphic) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.ResourceX, TheUI.ResourceY,
|
||||
TheUI.Resource.Graphic->Width,
|
||||
TheUI.Resource.Graphic->Height);
|
||||
}
|
||||
if (((MustRedraw & RedrawStatusLine) || MustRedraw&RedrawCosts) &&
|
||||
TheUI.StatusLine.Graphic) {
|
||||
InvalidateAreaAndCheckCursor(
|
||||
TheUI.StatusLineX, TheUI.StatusLineY,
|
||||
TheUI.StatusLine.Graphic->Width,
|
||||
TheUI.StatusLine.Graphic->Height);
|
||||
}
|
||||
if (MustRedraw & RedrawTimer) {
|
||||
// FIXME: Invalidate timer area
|
||||
}
|
||||
if (MustRedraw & RedrawMenu) {
|
||||
InvalidateMenuAreas();
|
||||
}
|
||||
|
||||
// And now as very last.. checking if the cursor needs a refresh
|
||||
InvalidateCursorAreas();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Enable everything to be drawn for next display update.
|
||||
** Used at start of mainloop (and possible refresh as user option)
|
||||
*/
|
||||
local void EnableDrawRefresh(void)
|
||||
{
|
||||
MustRedraw = RedrawEverything;
|
||||
MarkDrawEntireMap();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -579,7 +415,6 @@ global void GameMainLoop(void)
|
|||
Callbacks = &GameCallbacks;
|
||||
|
||||
SetVideoSync();
|
||||
EnableDrawRefresh();
|
||||
GameCursor = TheUI.Point.Cursor;
|
||||
GameRunning = 1;
|
||||
|
||||
|
@ -643,7 +478,6 @@ global void GameMainLoop(void)
|
|||
break;
|
||||
case 3: // minimap update
|
||||
UpdateMinimap();
|
||||
MustRedraw |= RedrawMinimap;
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
|
@ -698,9 +532,6 @@ global void GameMainLoop(void)
|
|||
if (!(FrameCounter % COLOR_CYCLE_SPEED)) {
|
||||
if (ColorCycleAll >= 0) {
|
||||
ColorCycle();
|
||||
} else {
|
||||
// FIXME: should only update when needed
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -709,20 +540,7 @@ global void GameMainLoop(void)
|
|||
RealVideoSyncSpeed = VideoSyncSpeed;
|
||||
VideoSyncSpeed = 3000;
|
||||
}
|
||||
if (FastForwardCycle >= GameCycle) {
|
||||
MustRedraw = RedrawEverything;
|
||||
}
|
||||
if (MustRedraw &&
|
||||
(FastForwardCycle <= GameCycle || GameCycle <= 10 ||
|
||||
!(GameCycle & 0x3f))) {
|
||||
if (Callbacks == &MenuCallbacks) {
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
if (CurrentMenu && CurrentMenu->Panel &&
|
||||
!strcmp(CurrentMenu->Panel, ScPanel)) {
|
||||
MustRedraw = RedrawEverything;
|
||||
}
|
||||
|
||||
if (FastForwardCycle <= GameCycle || GameCycle <= 10 || !(GameCycle & 0x3f)) {
|
||||
//FIXME: this might be better placed somewhere at front of the
|
||||
// program, as we now still have a game on the background and
|
||||
// need to go through hte game-menu or supply a pud-file
|
||||
|
@ -734,9 +552,6 @@ global void GameMainLoop(void)
|
|||
// XFlush
|
||||
//
|
||||
RealizeVideoMemory();
|
||||
#ifndef USE_OPENGL
|
||||
MustRedraw = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (FastForwardCycle == GameCycle) {
|
||||
|
@ -774,8 +589,7 @@ global void GameMainLoop(void)
|
|||
fprintf(stderr, "You have lost!\n");
|
||||
SetStatusLine("You have lost!");
|
||||
ProcessMenu("menu-defeated", 1);
|
||||
}
|
||||
else if (GameResult == GameVictory) {
|
||||
} else if (GameResult == GameVictory) {
|
||||
fprintf(stderr, "You have won!\n");
|
||||
SetStatusLine("You have won!");
|
||||
ProcessMenu("menu-victory", 1);
|
||||
|
|
|
@ -622,23 +622,6 @@ local int MissileVisibleInViewport(const Viewport* vp, const Missile* missile)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Check and sets if missile must be drawn on screen-map
|
||||
**
|
||||
** @param missile Missile to be checked.
|
||||
** @return True if map marked to be drawn, false otherwise.
|
||||
*/
|
||||
global int CheckMissileToBeDrawn(const Missile* missile)
|
||||
{
|
||||
int sx;
|
||||
int sy;
|
||||
int ex;
|
||||
int ey;
|
||||
|
||||
GetMissileMapArea(missile, &sx, &sy, &ex, &ey);
|
||||
return MarkDrawAreaMap(sx, sy, ex, ey);
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw missile.
|
||||
**
|
||||
|
@ -1219,9 +1202,6 @@ local void MissilesActionLoop(Missile** missiles)
|
|||
continue;
|
||||
}
|
||||
|
||||
// Mark missile area on screen to be drawn, if missile moves or disappears.
|
||||
CheckMissileToBeDrawn(missile);
|
||||
|
||||
MissileClassFunctions[missile->Type->Class](missile);
|
||||
|
||||
if (!missile->TTL) {
|
||||
|
|
|
@ -582,10 +582,6 @@ global void PlayerSetAiNum(Player* player, int ai)
|
|||
global void PlayerSetResource(Player* player, int resource, int value)
|
||||
{
|
||||
player->Resources[resource] = value;
|
||||
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -693,9 +689,6 @@ global void PlayerAddCosts(Player* player, const int* costs)
|
|||
for (i = 1; i < MaxCosts; ++i) {
|
||||
player->Resources[i] += costs[i];
|
||||
}
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -725,9 +718,6 @@ global void PlayerAddCostsFactor(Player* player, const int* costs, int factor)
|
|||
DebugLevel3("%d %d\n" _C_ i _C_ costs[i] * factor / 100);
|
||||
player->Resources[i] += costs[i] * factor / 100;
|
||||
}
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -743,9 +733,6 @@ global void PlayerSubCosts(Player* player, const int* costs)
|
|||
for (i = 1; i < MaxCosts; ++i) {
|
||||
player->Resources[i] -= costs[i];
|
||||
}
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -773,9 +760,6 @@ global void PlayerSubCostsFactor(Player* player, const int* costs, int factor)
|
|||
for (i = 1; i < MaxCosts; ++i) {
|
||||
player->Resources[i] -= costs[i] * 100 / factor;
|
||||
}
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,7 +81,6 @@ global void UnSelectAll(void)
|
|||
unit = Selected[--NumSelected];
|
||||
Selected[NumSelected] = NoUnitP; // FIXME: only needed for old code
|
||||
unit->Selected = 0;
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -139,7 +138,6 @@ global void ChangeSelectedUnits(Unit** units,int count)
|
|||
if (count > 1) {
|
||||
unit->LastGroup = GroupId;
|
||||
}
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
}
|
||||
NumSelected = n;
|
||||
|
@ -166,7 +164,6 @@ global void ChangeTeamSelectedUnits(Player* player, Unit** units, int adjust, in
|
|||
unit = TeamSelected[player->Player][--TeamNumSelected[player->Player]];
|
||||
unit->TeamSelected &= ~(1 << player->Player);
|
||||
TeamSelected[player->Player][TeamNumSelected[player->Player]] = NoUnitP; // FIXME: only needed for old code
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
// FALL THROUGH
|
||||
case 2:
|
||||
|
@ -175,7 +172,6 @@ global void ChangeTeamSelectedUnits(Player* player, Unit** units, int adjust, in
|
|||
TeamSelected[player->Player][TeamNumSelected[player->Player]++] = units[i];
|
||||
units[i]->TeamSelected |= 1 << player->Player;
|
||||
}
|
||||
CheckUnitToBeDrawn(units[i]);
|
||||
}
|
||||
DebugCheck(TeamNumSelected[player->Player] > MaxSelectable);
|
||||
break;
|
||||
|
@ -232,7 +228,6 @@ global int SelectUnit(Unit* unit)
|
|||
if (NumSelected > 1) {
|
||||
Selected[0]->LastGroup = unit->LastGroup = GroupId;
|
||||
}
|
||||
CheckUnitToBeDrawn(unit);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -295,7 +290,6 @@ global void UnSelectUnit(Unit* unit)
|
|||
|
||||
Selected[NumSelected] = NoUnitP; // FIXME: only needed for old code
|
||||
unit->Selected = 0;
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,7 +365,6 @@ global int SelectUnitsByType(Unit* base)
|
|||
Selected[0] = base;
|
||||
base->Selected = 1;
|
||||
NumSelected = 1;
|
||||
CheckUnitToBeDrawn(base);
|
||||
|
||||
// if unit isn't belonging to the player or allied player, or is a static unit
|
||||
// (like a building), only 1 unit can be selected at the same time.
|
||||
|
@ -400,7 +393,6 @@ global int SelectUnitsByType(Unit* base)
|
|||
}
|
||||
Selected[NumSelected++] = unit;
|
||||
unit->Selected = 1;
|
||||
CheckUnitToBeDrawn(unit);
|
||||
if (NumSelected == MaxSelectable) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -457,7 +457,6 @@ global int CastAdjustBuffs(Unit* caster, const SpellType* spell,
|
|||
if (action->Data.AdjustBuffs.InvincibilityTicks != BUFF_NOT_AFFECTED) {
|
||||
target->UnholyArmor = action->Data.AdjustBuffs.InvincibilityTicks;
|
||||
}
|
||||
CheckUnitToBeDrawn(target);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -696,7 +695,6 @@ global int CastSummon(Unit* caster, const SpellType* spell,
|
|||
// This is a hack to walk around behaviour of DropOutOnSide
|
||||
target->X++;
|
||||
DropOutOnSide(target, LookingW, 0, 0);
|
||||
CheckUnitToBeDrawn(target);
|
||||
}
|
||||
caster->Mana -= spell->ManaCost;
|
||||
return 1;
|
||||
|
|
|
@ -504,16 +504,23 @@ local void WaitCallbackExit(void)
|
|||
}
|
||||
|
||||
/**
|
||||
** Wait for any input.
|
||||
**
|
||||
** @param timeout Time in seconds to wait.
|
||||
** Show the title screens
|
||||
*/
|
||||
local void WaitForInput(int timeout)
|
||||
local void ShowTitleScreens(void)
|
||||
{
|
||||
EventCallback callbacks;
|
||||
int timeout;
|
||||
int i;
|
||||
int j;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
|
||||
if (!TitleScreens) {
|
||||
return;
|
||||
}
|
||||
|
||||
SetVideoSync();
|
||||
|
||||
callbacks.ButtonPressed = WaitCallbackKey;
|
||||
callbacks.ButtonReleased = WaitCallbackKey1;
|
||||
callbacks.MouseMoved = WaitCallbackMouse;
|
||||
|
@ -523,15 +530,43 @@ local void WaitForInput(int timeout)
|
|||
callbacks.KeyRepeated = WaitCallbackKey4;
|
||||
callbacks.NetworkEvent = NetworkEvent;
|
||||
|
||||
WaitNoEvent = 1;
|
||||
timeout *= CYCLES_PER_SECOND;
|
||||
while (timeout-- && WaitNoEvent) {
|
||||
WaitEventsOneFrame(&callbacks);
|
||||
}
|
||||
for (i = 0; TitleScreens[i]; ++i) {
|
||||
WaitNoEvent = 1;
|
||||
timeout = TitleScreens[i]->Timeout * CYCLES_PER_SECOND;
|
||||
|
||||
VideoClearScreen();
|
||||
Invalidate();
|
||||
RealizeVideoMemory();
|
||||
if (TitleScreens[i]->Music) {
|
||||
if (!strcmp(TitleScreens[i]->Music, "none") ||
|
||||
!PlayMusic(TitleScreens[i]->Music)) {
|
||||
StopMusic();
|
||||
}
|
||||
}
|
||||
if (PlayMovie(TitleScreens[i]->File,
|
||||
PlayMovieZoomScreen | PlayMovieKeepAspect)) {
|
||||
TitleScreenLabel** labels;
|
||||
|
||||
while (timeout-- && WaitNoEvent) {
|
||||
DisplayPicture(TitleScreens[i]->File);
|
||||
labels = TitleScreens[i]->Labels;
|
||||
if (labels && labels[0] && IsFontLoaded(labels[0]->Font)) {
|
||||
for (j = 0; labels[j]; ++j) {
|
||||
x = labels[j]->Xofs * VideoWidth / 640;
|
||||
y = labels[j]->Yofs * VideoWidth / 640;
|
||||
if (labels[j]->Flags & TitleFlagCenter) {
|
||||
x -= VideoTextLength(labels[j]->Font, labels[j]->Text) / 2;
|
||||
}
|
||||
VideoDrawText(x, y, labels[j]->Font, labels[j]->Text);
|
||||
}
|
||||
}
|
||||
Invalidate();
|
||||
RealizeVideoMemory();
|
||||
WaitEventsOneFrame(&callbacks);
|
||||
}
|
||||
}
|
||||
|
||||
VideoClearScreen();
|
||||
Invalidate();
|
||||
RealizeVideoMemory();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -735,11 +770,6 @@ local void PrintHeader(void)
|
|||
local int main1(int argc __attribute__ ((unused)),
|
||||
char** argv __attribute__ ((unused)))
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int x;
|
||||
int y;
|
||||
|
||||
PrintHeader();
|
||||
printf(
|
||||
"\n\nStratagus may be copied only under the terms of the GNU General Public License\
|
||||
|
@ -767,42 +797,13 @@ Use it at your own risk.\n\n");
|
|||
#endif
|
||||
|
||||
//
|
||||
// Show title screen.
|
||||
// Show title screens.
|
||||
//
|
||||
SetDefaultTextColors(FontYellow, FontWhite);
|
||||
LoadFonts();
|
||||
SetClipping(0, 0, VideoWidth - 1, VideoHeight - 1);
|
||||
VideoClearScreen();
|
||||
if (TitleScreens) {
|
||||
for (i = 0; TitleScreens[i]; ++i) {
|
||||
if (TitleScreens[i]->Music) {
|
||||
if (!strcmp(TitleScreens[i]->Music, "none") ||
|
||||
!PlayMusic(TitleScreens[i]->Music)) {
|
||||
StopMusic();
|
||||
}
|
||||
}
|
||||
if (PlayMovie(TitleScreens[i]->File,
|
||||
PlayMovieZoomScreen | PlayMovieKeepAspect)) {
|
||||
TitleScreenLabel** labels;
|
||||
|
||||
DisplayPicture(TitleScreens[i]->File);
|
||||
labels = TitleScreens[i]->Labels;
|
||||
if (labels && labels[0] && IsFontLoaded(labels[0]->Font)) {
|
||||
for (j = 0; labels[j]; ++j) {
|
||||
x = labels[j]->Xofs * VideoWidth / 640;
|
||||
y = labels[j]->Yofs * VideoWidth / 640;
|
||||
if (labels[j]->Flags & TitleFlagCenter) {
|
||||
x -= VideoTextLength(labels[j]->Font, labels[j]->Text) / 2;
|
||||
}
|
||||
VideoDrawText(x, y, labels[j]->Font, labels[j]->Text);
|
||||
}
|
||||
}
|
||||
Invalidate();
|
||||
RealizeVideoMemory();
|
||||
WaitForInput(TitleScreens[i]->Timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
ShowTitleScreens();
|
||||
|
||||
InitUnitsMemory(); // Units memory management
|
||||
PreMenuSetup(); // Load everything needed for menus
|
||||
|
|
|
@ -497,7 +497,6 @@ local void UpdateButtonPanelMultipleUnits(void)
|
|||
}
|
||||
|
||||
CurrentButtons = _current_buttons;
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -517,8 +516,6 @@ global void UpdateButtonPanel(void)
|
|||
CurrentButtons = NULL;
|
||||
|
||||
if (!NumSelected) { // no unit selected
|
||||
// FIXME: need only redraw if same state
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -675,7 +672,6 @@ global void UpdateButtonPanel(void)
|
|||
}
|
||||
|
||||
CurrentButtons = _current_buttons;
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -763,7 +759,6 @@ global void DoButtonButtonClicked(int button)
|
|||
CursorValue = CurrentButtons[button].Value;
|
||||
CurrentButtonLevel = 9; // level 9 is cancel-only
|
||||
UpdateButtonPanel();
|
||||
MustRedraw |= RedrawCursor;
|
||||
SetStatusLine("Select Target");
|
||||
}
|
||||
break;
|
||||
|
@ -805,7 +800,6 @@ global void DoButtonButtonClicked(int button)
|
|||
GameCursor = TheUI.Point.Cursor;
|
||||
CursorBuilding = NULL;
|
||||
CursorState = CursorStatePoint;
|
||||
MustRedraw |= RedrawCursor;
|
||||
break;
|
||||
|
||||
case ButtonCancelTrain:
|
||||
|
@ -835,7 +829,6 @@ global void DoButtonButtonClicked(int button)
|
|||
// FIXME: check is this =9 necessary?
|
||||
CurrentButtonLevel = 9; // level 9 is cancel-only
|
||||
UpdateButtonPanel();
|
||||
MustRedraw |= RedrawCursor;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -190,7 +190,6 @@ local void UiSelectGroup(unsigned group)
|
|||
|
||||
SelectGroup(group);
|
||||
SelectionChanged();
|
||||
MustRedraw |= RedrawMap | RedrawInfoPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,7 +225,6 @@ local void UiAddGroupToSelection(unsigned group)
|
|||
}
|
||||
|
||||
SelectionChanged();
|
||||
MustRedraw |= RedrawMap | RedrawInfoPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -465,7 +463,6 @@ local void UiToggleBigMap(void)
|
|||
|
||||
EnableRedraw = RedrawMap | RedrawCursor | RedrawMessage | RedrawMenu |
|
||||
RedrawTimer | RedrawAll;
|
||||
MustRedraw = RedrawEverything;
|
||||
SetStatusLine("Big map enabled");
|
||||
VideoClearScreen();
|
||||
} else {
|
||||
|
@ -477,7 +474,6 @@ local void UiToggleBigMap(void)
|
|||
SetViewportMode(TheUI.ViewportMode);
|
||||
|
||||
EnableRedraw = RedrawEverything;
|
||||
MustRedraw = RedrawEverything;
|
||||
SetStatusLine("Returning to old map");
|
||||
VideoClearScreen();
|
||||
}
|
||||
|
@ -667,26 +663,6 @@ local int CommandKey(int key)
|
|||
}
|
||||
break;
|
||||
|
||||
#if 0
|
||||
#ifdef DEBUG
|
||||
case '0':
|
||||
++ThisPlayer;
|
||||
if (ThisPlayer == &Players[PlayerMax]) {
|
||||
ThisPlayer = &Players[0];
|
||||
}
|
||||
MustRedraw = RedrawEverything;
|
||||
break;
|
||||
|
||||
case '1':
|
||||
--ThisPlayer;
|
||||
if (ThisPlayer < &Players[0]) {
|
||||
ThisPlayer = &Players[PlayerMax - 1];
|
||||
}
|
||||
MustRedraw = RedrawEverything;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
case 'p' & 0x1F:
|
||||
case 'p': // If pause-key didn't work
|
||||
case 'P': // CTRL-P, ALT-P Toggle pause
|
||||
|
|
|
@ -764,9 +764,6 @@ global void UpdateMessages(void)
|
|||
MessagesScrollY = 0;
|
||||
ShiftMessages();
|
||||
}
|
||||
MustRedraw |= RedrawMessage;
|
||||
// FIXME: for performance the minimal area covered by msg's should be used
|
||||
MarkDrawEntireMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -919,9 +916,6 @@ global void SetMessage(const char* fmt, ...)
|
|||
return;
|
||||
}
|
||||
AddMessage(temp);
|
||||
MustRedraw |= RedrawMessage;
|
||||
// FIXME: for performance the minimal area covered by msg's should be used
|
||||
MarkDrawEntireMap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -955,10 +949,6 @@ global void SetMessageEvent(int x, int y, const char* fmt, ...)
|
|||
MessagesEventY[MessagesEventCount] = y;
|
||||
MessagesEventIndex = MessagesEventCount;
|
||||
++MessagesEventCount;
|
||||
|
||||
MustRedraw |= RedrawMessage;
|
||||
//FIXME: for performance the minimal area covered by msg's should be used
|
||||
MarkDrawEntireMap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1031,7 +1021,6 @@ global void DrawStatusLine(void)
|
|||
global void SetStatusLine(char* status)
|
||||
{
|
||||
if (KeyState != KeyStateInput && strcmp(StatusLine, status)) {
|
||||
MustRedraw |= RedrawStatusLine;
|
||||
strncpy(StatusLine, status, sizeof(StatusLine) - 1);
|
||||
StatusLine[sizeof(StatusLine) - 1] = '\0';
|
||||
}
|
||||
|
@ -1112,26 +1101,22 @@ global void SetCosts(int mana, int food, const int* costs)
|
|||
|
||||
if (CostsMana != mana) {
|
||||
CostsMana = mana;
|
||||
MustRedraw |= RedrawCosts;
|
||||
}
|
||||
|
||||
if (CostsFood != food) {
|
||||
CostsFood = food;
|
||||
MustRedraw |= RedrawCosts;
|
||||
}
|
||||
|
||||
if (costs) {
|
||||
for (i = 0; i < MaxCosts; ++i) {
|
||||
if (Costs[i] != costs[i]) {
|
||||
Costs[i] = costs[i];
|
||||
MustRedraw |= RedrawCosts;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < MaxCosts; ++i) {
|
||||
if (Costs[i]) {
|
||||
Costs[i] = 0;
|
||||
MustRedraw |= RedrawCosts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1333,8 +1318,6 @@ global void UpdateTimer(void)
|
|||
}
|
||||
}
|
||||
GameTimer.LastUpdate = GameCycle;
|
||||
// FIXME: only redraw when the displayed time changes
|
||||
MustRedraw |= RedrawTimer;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -169,22 +169,11 @@ global Menu* FindMenu(const char* menu_id)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Invalidate previously redrawn menu areas.
|
||||
*/
|
||||
global void InvalidateMenuAreas(void)
|
||||
{
|
||||
InvalidateAreaAndCheckCursor(MenuRedrawX, MenuRedrawY,
|
||||
MenuRedrawW, MenuRedrawH);
|
||||
MustRedraw &= ~RedrawMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
** Set menu backgound and draw it.
|
||||
*/
|
||||
global void MenusSetBackground(void)
|
||||
{
|
||||
DestroyCursorBackground();
|
||||
if (!Menusbgnd) {
|
||||
Menusbgnd = LoadGraphic(MenuBackground);
|
||||
ResizeGraphic(Menusbgnd, VideoWidth, VideoHeight);
|
||||
|
@ -1015,7 +1004,6 @@ global void DrawMenu(Menu* menu)
|
|||
Menuitem* mip;
|
||||
|
||||
if (menu == NULL) {
|
||||
MustRedraw &= ~RedrawMenu;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1236,7 +1224,6 @@ local void PasteFromClipboard(Menuitem* mi)
|
|||
XFree(clipboard);
|
||||
}
|
||||
#endif
|
||||
MustRedraw |= RedrawMenu;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1281,7 +1268,6 @@ inkey:
|
|||
case '\b': case '\177':
|
||||
if (mi->d.input.nch > 0) {
|
||||
strcpy(mi->d.input.buffer + (--mi->d.input.nch), "~!_");
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
|
@ -1291,7 +1277,6 @@ inkey:
|
|||
case KeyCodeDelete:
|
||||
mi->d.input.nch = 0;
|
||||
strcpy(mi->d.input.buffer, "~!_");
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
default:
|
||||
if (KeyModifiers&ModifierAlt) {
|
||||
|
@ -1304,14 +1289,12 @@ inkey:
|
|||
} else if (key == 'u' || key == 'U') {
|
||||
mi->d.input.nch = 0;
|
||||
strcpy(mi->d.input.buffer, "~!_");
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
} else if (key >= 32 && key < 0x100) {
|
||||
if (mi->d.input.nch < mi->d.input.maxch &&
|
||||
VideoTextLength(mi->font, mi->d.input.buffer) + 8 < mi->d.input.xsize) {
|
||||
mi->d.input.buffer[mi->d.input.nch++] = keychar;
|
||||
strcpy(mi->d.input.buffer + mi->d.input.nch, "~!_");
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1391,7 +1374,6 @@ normkey:
|
|||
break;
|
||||
}
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
if (mi->d.pulldown.action) {
|
||||
(*mi->d.pulldown.action)(mi, mi->d.pulldown.curopt);
|
||||
}
|
||||
|
@ -1421,7 +1403,6 @@ normkey:
|
|||
if (mi->d.listbox.action) {
|
||||
(*mi->d.listbox.action)(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
case MI_TYPE_VSLIDER:
|
||||
if (key == KeyCodeDown) {
|
||||
|
@ -1432,7 +1413,6 @@ normkey:
|
|||
if (mi->d.vslider.action) {
|
||||
(*mi->d.vslider.action)(mi, 2);
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1461,7 +1441,6 @@ normkey:
|
|||
if (mi->d.hslider.action) {
|
||||
(*mi->d.hslider.action)(mi);
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -1494,7 +1473,6 @@ normkey:
|
|||
mi->flags |= MenuButtonSelected;
|
||||
menu->Items[MenuButtonCurSel].flags &= ~MenuButtonSelected;
|
||||
MenuButtonCurSel = mi - menu->Items;
|
||||
MustRedraw |= RedrawMenu;
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
|
@ -1520,7 +1498,6 @@ normkey:
|
|||
}
|
||||
mi->flags |= MenuButtonSelected;
|
||||
MenuButtonCurSel = mi - menu->Items;
|
||||
MustRedraw |= RedrawMenu;
|
||||
goto inkey;
|
||||
}
|
||||
default:
|
||||
|
@ -1583,7 +1560,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
Menu* menu;
|
||||
int ox;
|
||||
int oy;
|
||||
int redraw_flag;
|
||||
|
||||
ox = CursorX;
|
||||
oy = CursorY; // Old position for rel movement.
|
||||
|
@ -1597,7 +1573,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
|
||||
n = menu->NumItems;
|
||||
MenuButtonUnderCursor = -1;
|
||||
redraw_flag = 0;
|
||||
|
||||
// check active (popped-up) pulldown first, as it may overlay other menus!
|
||||
mi = menu->Items;
|
||||
|
@ -1628,7 +1603,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
}
|
||||
if (j >= -1 && j < mi->d.pulldown.noptions && j != mi->d.pulldown.cursel) {
|
||||
mi->d.pulldown.cursel = j;
|
||||
redraw_flag = 1;
|
||||
if (mi->d.pulldown.action) {
|
||||
(*mi->d.pulldown.action)(mi, mi->d.pulldown.cursel);
|
||||
}
|
||||
|
@ -1650,7 +1624,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
j = (y - ys) / h;
|
||||
if (j >= 0 && j < mi->d.pulldown.noptions && j != mi->d.pulldown.cursel) {
|
||||
mi->d.pulldown.cursel = j;
|
||||
redraw_flag = 1;
|
||||
if (mi->d.pulldown.action) {
|
||||
(*mi->d.pulldown.action)(mi, mi->d.pulldown.cursel);
|
||||
}
|
||||
|
@ -1677,7 +1650,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
y < ys - 4 || y > ys + VideoTextHeight(mi->font) + 5) {
|
||||
if (!(mi->flags & MenuButtonClicked)) {
|
||||
if (mi->flags & MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
mi->flags &= ~MenuButtonActive;
|
||||
}
|
||||
}
|
||||
|
@ -1694,7 +1666,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
y > ys + mi->d.gem.ysize)) {
|
||||
if (!(mi->flags & MenuButtonClicked)) {
|
||||
if (mi->flags & MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
mi->flags &= ~MenuButtonActive;
|
||||
}
|
||||
}
|
||||
|
@ -1708,7 +1679,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
y > ys + mi->d.button.ysize) {
|
||||
if (!(mi->flags & MenuButtonClicked)) {
|
||||
if (mi->flags & MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
mi->flags &= ~MenuButtonActive;
|
||||
}
|
||||
}
|
||||
|
@ -1722,7 +1692,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
|| y < ys || y > ys + mi->d.input.ysize) {
|
||||
if (!(mi->flags & MenuButtonClicked)) {
|
||||
if (mi->flags & MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
mi->flags &= ~MenuButtonActive;
|
||||
}
|
||||
}
|
||||
|
@ -1740,7 +1709,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
y > ys + mi->d.pulldown.ysize) {
|
||||
if (!(mi->flags & MenuButtonClicked)) {
|
||||
if (mi->flags & MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
mi->flags &= ~MenuButtonActive;
|
||||
}
|
||||
}
|
||||
|
@ -1754,7 +1722,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
y > ys + mi->d.listbox.ysize) {
|
||||
if (!(mi->flags & MenuButtonClicked)) {
|
||||
if (mi->flags & MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
mi->flags &= ~MenuButtonActive;
|
||||
}
|
||||
}
|
||||
|
@ -1768,7 +1735,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
if (mi->d.listbox.cursel != mi->d.listbox.curopt) {
|
||||
mi->d.listbox.dohandler = 0;
|
||||
mi->d.listbox.curopt = mi->d.listbox.cursel;
|
||||
redraw_flag = 1;
|
||||
if (mi->d.listbox.action) {
|
||||
(*mi->d.listbox.action)(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
}
|
||||
|
@ -1785,7 +1751,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
y > ys + mi->d.vslider.ysize) {
|
||||
if (!(mi->flags & MenuButtonClicked)) {
|
||||
if (mi->flags & MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
mi->flags &= ~MenuButtonActive;
|
||||
}
|
||||
}
|
||||
|
@ -1846,7 +1811,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
y > ys + mi->d.hslider.ysize) {
|
||||
if (!(mi->flags & MenuButtonClicked)) {
|
||||
if (mi->flags & MenuButtonActive) {
|
||||
redraw_flag = 1;
|
||||
mi->flags &= ~MenuButtonActive;
|
||||
}
|
||||
}
|
||||
|
@ -1896,7 +1860,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
if (mi->d.hslider.action) {
|
||||
(*mi->d.hslider.action)(mi);
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1917,7 +1880,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
case MI_TYPE_HSLIDER:
|
||||
case MI_TYPE_TEXT:
|
||||
if (!(mi->flags & MenuButtonActive)) {
|
||||
redraw_flag = 1;
|
||||
mi->flags |= MenuButtonActive;
|
||||
}
|
||||
MenuButtonUnderCursor = i;
|
||||
|
@ -1925,7 +1887,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
break;
|
||||
case MI_TYPE_INPUT:
|
||||
if (!(mi->flags & MenuButtonActive)) {
|
||||
redraw_flag = 1;
|
||||
mi->flags |= MenuButtonActive;
|
||||
}
|
||||
if (MouseButtons & LeftButton
|
||||
|
@ -1947,7 +1908,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
(mi->d.input.maxch >= 7)) {
|
||||
mi->d.input.nch =
|
||||
sprintf(mi->d.input.buffer, "%d~!_", num) - 3;
|
||||
redraw_flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1958,9 +1918,6 @@ local void MenuHandleMouseMove(int x, int y)
|
|||
}
|
||||
}
|
||||
}
|
||||
if (redraw_flag) {
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,7 +1958,6 @@ local void MenuHandleButtonDown(unsigned b __attribute__((unused)))
|
|||
}
|
||||
MenuButtonCurSel = MenuButtonUnderCursor;
|
||||
mi->flags |= MenuButtonClicked | MenuButtonSelected;
|
||||
MustRedraw |= RedrawMenu;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -2095,14 +2051,12 @@ local void MenuHandleButtonDown(unsigned b __attribute__((unused)))
|
|||
}
|
||||
mi[1].d.vslider.percent = 100 * (mi->d.listbox.curopt + mi->d.listbox.startline)
|
||||
/ (mi->d.listbox.noptions - 1);
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
case MI_TYPE_VSLIDER:
|
||||
mi->d.vslider.cflags |= MI_CFLAGS_UP;
|
||||
if (mi->d.vslider.action) {
|
||||
(*mi->d.vslider.action)(mi, 2);
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
case MI_TYPE_HSLIDER:
|
||||
mi->d.hslider.percent -= 10;
|
||||
|
@ -2112,7 +2066,6 @@ local void MenuHandleButtonDown(unsigned b __attribute__((unused)))
|
|||
if (mi->d.hslider.action) {
|
||||
(*mi->d.hslider.action)(mi);
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
case MI_TYPE_PULLDOWN:
|
||||
if (mi->d.pulldown.curopt) {
|
||||
|
@ -2121,7 +2074,6 @@ local void MenuHandleButtonDown(unsigned b __attribute__((unused)))
|
|||
(*mi->d.pulldown.action)(mi, mi->d.pulldown.curopt);
|
||||
}
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2151,14 +2103,12 @@ local void MenuHandleButtonDown(unsigned b __attribute__((unused)))
|
|||
}
|
||||
mi[1].d.vslider.percent = 100 * (mi->d.listbox.curopt + mi->d.listbox.startline)
|
||||
/ (mi->d.listbox.noptions - 1);
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
case MI_TYPE_VSLIDER:
|
||||
mi->d.vslider.cflags |= MI_CFLAGS_DOWN;
|
||||
if (mi->d.vslider.action) {
|
||||
(*mi->d.vslider.action)(mi, 2);
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
case MI_TYPE_HSLIDER:
|
||||
mi->d.hslider.percent += 10;
|
||||
|
@ -2168,7 +2118,6 @@ local void MenuHandleButtonDown(unsigned b __attribute__((unused)))
|
|||
if (mi->d.hslider.action) {
|
||||
(*mi->d.hslider.action)(mi);
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
case MI_TYPE_PULLDOWN:
|
||||
if (mi->d.pulldown.curopt < mi->d.pulldown.noptions - 1) {
|
||||
|
@ -2177,7 +2126,6 @@ local void MenuHandleButtonDown(unsigned b __attribute__((unused)))
|
|||
(*mi->d.pulldown.action)(mi, mi->d.pulldown.curopt);
|
||||
}
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2309,9 +2257,7 @@ local void MenuHandleButtonUp(unsigned b)
|
|||
}
|
||||
}
|
||||
if (redraw_flag) {
|
||||
MustRedraw |= RedrawMenu;
|
||||
|
||||
MenuHandleMouseMove(CursorX,CursorY);
|
||||
MenuHandleMouseMove(CursorX, CursorY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2376,7 +2322,6 @@ local void PopMenu(void)
|
|||
global void EndMenu(void)
|
||||
{
|
||||
CursorOn = CursorOnUnknown;
|
||||
MustRedraw = RedrawEverything;
|
||||
PopMenu();
|
||||
|
||||
if (!CurrentMenu && Callbacks != &GameCallbacks &&
|
||||
|
@ -2421,9 +2366,6 @@ global void ProcessMenu(const char* menu_id, int loop)
|
|||
}
|
||||
|
||||
ButtonUnderCursor = -1;
|
||||
HideAnyCursor();
|
||||
DestroyCursorBackground();
|
||||
MustRedraw |= RedrawCursor;
|
||||
CursorState = CursorStatePoint;
|
||||
GameCursor = TheUI.Point.Cursor;
|
||||
menu = FindMenu(menu_id);
|
||||
|
@ -2494,7 +2436,6 @@ global void ProcessMenu(const char* menu_id, int loop)
|
|||
MenuHandleMouseMove(CursorX,CursorY); // This activates buttons as appropriate!
|
||||
}
|
||||
|
||||
MustRedraw = RedrawEverything;
|
||||
if (loop) {
|
||||
while (CurrentMenu != NULL) {
|
||||
PlayListAdvance();
|
||||
|
@ -2502,26 +2443,15 @@ global void ProcessMenu(const char* menu_id, int loop)
|
|||
PlaySectionMusic(PlaySectionUnknown);
|
||||
}
|
||||
|
||||
DebugLevel3("MustRedraw: 0x%08x\n" _C_ MustRedraw);
|
||||
if (MustRedraw) {
|
||||
if (CurrentMenu->Panel && !strcmp(CurrentMenu->Panel, ScPanel)) {
|
||||
MustRedraw = RedrawEverything;
|
||||
}
|
||||
if (MustRedraw == RedrawEverything) {
|
||||
InterfaceState = IfaceStateNormal;
|
||||
UpdateDisplay();
|
||||
InterfaceState = IfaceStateMenu;
|
||||
MustRedraw = RedrawMenu;
|
||||
} else {
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
InterfaceState = IfaceStateNormal;
|
||||
UpdateDisplay();
|
||||
InterfaceState = IfaceStateMenu;
|
||||
|
||||
RealizeVideoMemory();
|
||||
oldncr = NetConnectRunning;
|
||||
WaitEventsOneFrame(&MenuCallbacks);
|
||||
if (NetConnectRunning == 2) {
|
||||
NetworkProcessClientRequest();
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
if (NetConnectRunning == 1) {
|
||||
NetworkProcessServerRequest();
|
||||
|
@ -2533,8 +2463,6 @@ global void ProcessMenu(const char* menu_id, int loop)
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
InvalidateAreaAndCheckCursor(MenuRedrawX, MenuRedrawY, MenuRedrawW, MenuRedrawH);
|
||||
}
|
||||
|
||||
if (loop) {
|
||||
|
|
|
@ -834,11 +834,8 @@ local void GameMenuReturn(void)
|
|||
while (CurrentMenu) {
|
||||
EndMenu();
|
||||
}
|
||||
MustRedraw &= ~RedrawMenu;
|
||||
InterfaceState = IfaceStateNormal;
|
||||
ClearStatusLine();
|
||||
MarkDrawEntireMap(); //FIXME: some tiles could be left as they were?
|
||||
MustRedraw=RedrawEverything;
|
||||
GamePaused = 0;
|
||||
}
|
||||
|
||||
|
@ -1074,7 +1071,6 @@ local void SaveGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt--;
|
||||
mi->d.listbox.startline++;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
} else if (mi[1].d.vslider.cflags&MI_CFLAGS_UP) {
|
||||
if (mi->d.listbox.curopt + mi->d.listbox.startline > 0) {
|
||||
|
@ -1083,7 +1079,6 @@ local void SaveGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt++;
|
||||
mi->d.listbox.startline--;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
SaveGameLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
|
@ -1140,7 +1135,6 @@ local void SaveGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.startline+mi->d.listbox.curopt >= mi->d.listbox.noptions);
|
||||
|
||||
SaveGameLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1319,7 +1313,6 @@ local void LoadGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt--;
|
||||
mi->d.listbox.startline++;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
} else if (mi[1].d.vslider.cflags & MI_CFLAGS_UP) {
|
||||
if (mi->d.listbox.curopt + mi->d.listbox.startline > 0) {
|
||||
|
@ -1328,7 +1321,6 @@ local void LoadGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt++;
|
||||
mi->d.listbox.startline--;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
LoadGameLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
|
@ -1385,7 +1377,6 @@ local void LoadGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.startline+mi->d.listbox.curopt >= mi->d.listbox.noptions);
|
||||
|
||||
LoadGameLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -2560,7 +2551,6 @@ local void TipsShowTipsText(Menuitem *mi)
|
|||
ShowTips = 0;
|
||||
mi->menu->Items[1].d.gem.state = MI_GSTATE_UNCHECKED;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2759,7 +2749,6 @@ local void MultiScenSelectMenu(void)
|
|||
*/
|
||||
local void SinglePlayerGameMenu(void)
|
||||
{
|
||||
DestroyCursorBackground();
|
||||
GuiGameStarted = 0;
|
||||
ProcessMenu("menu-custom-game", 1);
|
||||
if (GuiGameStarted) {
|
||||
|
@ -3102,7 +3091,6 @@ local void TerminateNetConnect(void)
|
|||
|
||||
DebugLevel1Fn("NetLocalState %d\n" _C_ NetLocalState);
|
||||
NetConnectRunning = 2;
|
||||
DestroyCursorBackground();
|
||||
GuiGameStarted = 0;
|
||||
ProcessMenu("menu-net-multi-client", 1);
|
||||
if (GuiGameStarted) {
|
||||
|
@ -3117,7 +3105,6 @@ local void TerminateNetConnect(void)
|
|||
*/
|
||||
local void CreateNetGameMenu(void)
|
||||
{
|
||||
DestroyCursorBackground();
|
||||
GuiGameStarted = 0;
|
||||
ProcessMenu("menu-multi-setup", 1);
|
||||
if (GuiGameStarted) {
|
||||
|
@ -3131,7 +3118,6 @@ local void CreateNetGameMenu(void)
|
|||
*/
|
||||
local void CreateInternetGameMenu(void)
|
||||
{
|
||||
DestroyCursorBackground();
|
||||
GuiGameStarted = 0;
|
||||
AddGameServer();
|
||||
ProcessMenu("menu-multi-setup", 1);
|
||||
|
@ -3486,7 +3472,6 @@ local void ScenSelectTPMSAction(Menuitem *mi, int i __attribute__((unused)))
|
|||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
mi[1].d.hslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3509,7 +3494,6 @@ local void ScenSelectVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt--;
|
||||
mi->d.listbox.startline++;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
} else if (mi[1].d.vslider.cflags & MI_CFLAGS_UP) {
|
||||
if (mi->d.listbox.curopt + mi->d.listbox.startline > 0) {
|
||||
|
@ -3518,7 +3502,6 @@ local void ScenSelectVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt++;
|
||||
mi->d.listbox.startline--;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
ScenSelectLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
|
@ -3571,7 +3554,6 @@ local void ScenSelectVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.startline + mi->d.listbox.curopt >= mi->d.listbox.noptions);
|
||||
|
||||
ScenSelectLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -3591,11 +3573,9 @@ local void KeystrokeHelpVSAction(Menuitem *mi, int i)
|
|||
case 2: // key - down
|
||||
j = ((mi->d.vslider.percent + 1) * (nKeyStrokeHelps - 11)) / 100;
|
||||
if (mi->d.vslider.cflags&MI_CFLAGS_DOWN && j < nKeyStrokeHelps - 11) {
|
||||
j++;
|
||||
MustRedraw |= RedrawMenu;
|
||||
j++;
|
||||
} else if (mi->d.vslider.cflags & MI_CFLAGS_UP && j > 0) {
|
||||
j--;
|
||||
MustRedraw |= RedrawMenu;
|
||||
j--;
|
||||
}
|
||||
if (i == 2) {
|
||||
mi->d.vslider.cflags &= ~(MI_CFLAGS_DOWN | MI_CFLAGS_UP);
|
||||
|
@ -3606,7 +3586,6 @@ local void KeystrokeHelpVSAction(Menuitem *mi, int i)
|
|||
if ((mi->d.vslider.cflags&MI_CFLAGS_KNOB) && (mi->flags&MenuButtonClicked)) {
|
||||
j = ((mi->d.vslider.curper + 1) * (nKeyStrokeHelps - 11)) / 100;
|
||||
mi->d.vslider.percent = mi->d.vslider.curper;
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -3727,7 +3706,6 @@ local void ScenSelectFolder(void)
|
|||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
mi[1].d.hslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3763,7 +3741,6 @@ local void ScenSelectOk(void)
|
|||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
mi[1].d.hslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
} else {
|
||||
strcpy(ScenSelectFileName, fl[i].name); // Final map name
|
||||
EndMenu();
|
||||
|
@ -4749,7 +4726,6 @@ global int NetClientSelectScenario(void)
|
|||
global void NetConnectForceDisplayUpdate(void)
|
||||
{
|
||||
MultiGamePlayerSelectorsUpdate(2);
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4783,8 +4759,6 @@ global void NetClientUpdateState(void)
|
|||
|
||||
MultiClientUpdate(0);
|
||||
DebugLevel1Fn("MultiClientMenuRedraw\n");
|
||||
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5168,7 +5142,6 @@ local void EditorMainLoadFolder(void)
|
|||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
mi[1].d.hslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5204,7 +5177,6 @@ local void EditorMainLoadOk(void)
|
|||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
mi[1].d.hslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
} else {
|
||||
strcpy(ScenSelectFileName, fl[i].name); // Final map name
|
||||
EndMenu();
|
||||
|
@ -5336,7 +5308,6 @@ local void EditorMainLoadVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt--;
|
||||
mi->d.listbox.startline++;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
} else if (mi[1].d.vslider.cflags & MI_CFLAGS_UP) {
|
||||
if (mi->d.listbox.curopt + mi->d.listbox.startline > 0) {
|
||||
|
@ -5345,7 +5316,6 @@ local void EditorMainLoadVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt++;
|
||||
mi->d.listbox.startline--;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
EditorMainLoadLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
|
@ -5401,7 +5371,6 @@ local void EditorMainLoadVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.startline+mi->d.listbox.curopt >= mi->d.listbox.noptions);
|
||||
|
||||
EditorMainLoadLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -5474,7 +5443,6 @@ local void EditorLoadOk(void)
|
|||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
mi[1].d.hslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
} else {
|
||||
strcpy(ScenSelectFileName, fl[i].name); // Final map name
|
||||
EndMenu();
|
||||
|
@ -6028,7 +5996,6 @@ local void EditorSaveFolder(void)
|
|||
mi->d.listbox.startline = 0;
|
||||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6063,7 +6030,6 @@ local void EditorSaveOk(void)
|
|||
mi->d.listbox.startline = 0;
|
||||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
} else {
|
||||
strcpy(ScenSelectFileName, menu->Items[3].d.input.buffer); // Final map name
|
||||
ScenSelectFileName[strlen(ScenSelectFileName) - 3] = '\0';
|
||||
|
@ -6166,7 +6132,6 @@ local void EditorSaveVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt--;
|
||||
mi->d.listbox.startline++;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
} else if (mi[1].d.vslider.cflags & MI_CFLAGS_UP) {
|
||||
if (mi->d.listbox.curopt + mi->d.listbox.startline > 0) {
|
||||
|
@ -6175,7 +6140,6 @@ local void EditorSaveVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt++;
|
||||
mi->d.listbox.startline--;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
EditorSaveLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
|
@ -6228,7 +6192,6 @@ local void EditorSaveVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.startline + mi->d.listbox.curopt >= mi->d.listbox.noptions);
|
||||
|
||||
EditorSaveLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -6302,11 +6265,9 @@ local void EditorEndMenu(void)
|
|||
CursorOn = CursorOnUnknown;
|
||||
CurrentMenu = NULL;
|
||||
|
||||
MustRedraw = RedrawEverything;
|
||||
InterfaceState = IfaceStateNormal;
|
||||
EditorUpdateDisplay();
|
||||
InterfaceState = IfaceStateMenu;
|
||||
MustRedraw = RedrawMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6511,7 +6472,6 @@ local void ReplayGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt--;
|
||||
mi->d.listbox.startline++;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
} else if (mi[1].d.vslider.cflags & MI_CFLAGS_UP) {
|
||||
if (mi->d.listbox.curopt + mi->d.listbox.startline > 0) {
|
||||
|
@ -6520,7 +6480,6 @@ local void ReplayGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.curopt++;
|
||||
mi->d.listbox.startline--;
|
||||
}
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
ReplayGameLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
|
@ -6577,7 +6536,6 @@ local void ReplayGameVSAction(Menuitem *mi, int i)
|
|||
mi->d.listbox.startline + mi->d.listbox.curopt >= mi->d.listbox.noptions);
|
||||
|
||||
ReplayGameLBAction(mi, mi->d.listbox.curopt + mi->d.listbox.startline);
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -6615,7 +6573,6 @@ local void ReplayGameFolder(void)
|
|||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
mi[1].d.hslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6658,7 +6615,6 @@ local void ReplayGameOk(void)
|
|||
mi->d.listbox.curopt = 0;
|
||||
mi[1].d.vslider.percent = 0;
|
||||
mi[1].d.hslider.percent = 0;
|
||||
MustRedraw |= RedrawMenu;
|
||||
} else {
|
||||
strcpy(ScenSelectFileName, fl[i].name); // Final map name
|
||||
|
||||
|
@ -6887,7 +6843,6 @@ local void ShowMetaServerList(void)
|
|||
Invalidate();
|
||||
MenusSetBackground();
|
||||
|
||||
DestroyCursorBackground();
|
||||
GuiGameStarted = 0;
|
||||
ProcessMenu("metaserver-list", 1);
|
||||
if (GuiGameStarted) {
|
||||
|
|
|
@ -85,7 +85,6 @@ global enum _cursor_on_ CursorOn=CursorOnUnknown; /// Cursor on field
|
|||
global void CancelBuildingMode(void)
|
||||
{
|
||||
CursorBuilding = NULL;
|
||||
MustRedraw |= RedrawCursor;
|
||||
ClearStatusLine();
|
||||
ClearCosts();
|
||||
CurrentButtonLevel = 0; // reset unit buttons to normal
|
||||
|
@ -396,7 +395,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaMenu;
|
||||
ButtonUnderCursor = ButtonUnderMenu;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +407,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaMenu;
|
||||
ButtonUnderCursor = ButtonUnderNetworkMenu;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -421,7 +418,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaMenu;
|
||||
ButtonUnderCursor = ButtonUnderNetworkDiplomacy;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +431,6 @@ local void HandleMouseOn(int x, int y)
|
|||
if (CurrentButtons && CurrentButtons[i].Pos != -1) {
|
||||
ButtonUnderCursor = i;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +445,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaTransporting;
|
||||
ButtonUnderCursor = i;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -466,7 +460,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaTraining;
|
||||
ButtonUnderCursor = 0;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -479,7 +472,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaTraining;
|
||||
ButtonUnderCursor = i;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +484,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaUpgrading;
|
||||
ButtonUnderCursor = 0;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
return;
|
||||
}
|
||||
} else if (Selected[0]->Orders[0].Action == UnitActionResearch && !BigMapMode) {
|
||||
|
@ -503,7 +494,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaResearching;
|
||||
ButtonUnderCursor = 0;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -517,7 +507,6 @@ local void HandleMouseOn(int x, int y)
|
|||
ButtonAreaUnderCursor = ButtonAreaSelected;
|
||||
ButtonUnderCursor = 0;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -526,31 +515,19 @@ local void HandleMouseOn(int x, int y)
|
|||
TheUI.NumSelectedButtons - 1 : NumSelected - 1;
|
||||
for (; i >= 0; --i) {
|
||||
if (x >= TheUI.SelectedButtons[i].X &&
|
||||
x < TheUI.SelectedButtons[i].X + TheUI.SelectedButtons[i].Width + 7 &&
|
||||
y >= TheUI.SelectedButtons[i].Y &&
|
||||
y < TheUI.SelectedButtons[i].Y + TheUI.SelectedButtons[i].Height + 7) {
|
||||
ButtonAreaUnderCursor = ButtonAreaSelected;
|
||||
ButtonUnderCursor = i;
|
||||
CursorOn = CursorOnButton;
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
return;
|
||||
x < TheUI.SelectedButtons[i].X + TheUI.SelectedButtons[i].Width + 7 &&
|
||||
y >= TheUI.SelectedButtons[i].Y &&
|
||||
y < TheUI.SelectedButtons[i].Y + TheUI.SelectedButtons[i].Height + 7) {
|
||||
ButtonAreaUnderCursor = ButtonAreaSelected;
|
||||
ButtonUnderCursor = i;
|
||||
CursorOn = CursorOnButton;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ButtonUnderCursor != -1) { // remove old display
|
||||
if (ButtonAreaUnderCursor == ButtonAreaMenu) {
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
} else if (ButtonAreaUnderCursor == ButtonAreaSelected ||
|
||||
ButtonAreaUnderCursor == ButtonAreaTraining ||
|
||||
ButtonAreaUnderCursor == ButtonAreaUpgrading ||
|
||||
ButtonAreaUnderCursor == ButtonAreaResearching ||
|
||||
ButtonAreaUnderCursor == ButtonAreaTransporting) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
} else {
|
||||
MustRedraw |= RedrawButtonPanel;
|
||||
}
|
||||
ButtonAreaUnderCursor = -1;
|
||||
ButtonUnderCursor = -1;
|
||||
}
|
||||
|
@ -810,9 +787,6 @@ global void UIHandleMouseMove(int x, int y)
|
|||
//
|
||||
if (UnitUnderCursor && !UnitUnderCursor->Type->Decoration &&
|
||||
(UnitVisible(UnitUnderCursor, ThisPlayer) || ReplayRevealMap)) {
|
||||
if (NumSelected == 0) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
GameCursor = TheUI.Glass.Cursor;
|
||||
}
|
||||
|
||||
|
@ -1267,7 +1241,6 @@ local void DoSelectionButtons(int num,unsigned button __attribute__((unused)))
|
|||
ClearCosts();
|
||||
CurrentButtonLevel = 0; // reset unit buttons to normal
|
||||
SelectionChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
//.............................................................................
|
||||
|
@ -1298,7 +1271,6 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused)))
|
|||
GameCursor = TheUI.Point.Cursor;
|
||||
CurrentButtonLevel = 0;
|
||||
UpdateButtonPanel();
|
||||
MustRedraw |= RedrawButtonPanel | RedrawCursor;
|
||||
|
||||
sx = CursorX - vp->X + TileSizeX * vp->MapX + vp->OffsetX;
|
||||
sy = CursorY - vp->Y + TileSizeY * vp->MapY + vp->OffsetY;
|
||||
|
@ -1333,7 +1305,6 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused)))
|
|||
GameCursor = TheUI.Point.Cursor;
|
||||
CurrentButtonLevel = 0; // reset unit buttons to normal
|
||||
UpdateButtonPanel();
|
||||
MustRedraw |= RedrawButtonPanel | RedrawCursor;
|
||||
if (ClickMissile) {
|
||||
MakeLocalMissile(MissileTypeByIdent(ClickMissile),
|
||||
sx + TileSizeX / 2, sy + TileSizeY / 2, 0, 0);
|
||||
|
@ -1359,7 +1330,6 @@ local void UISelectStateButtonDown(unsigned button __attribute__((unused)))
|
|||
GameCursor = TheUI.Point.Cursor;
|
||||
CurrentButtonLevel = 0; // reset unit buttons to normal
|
||||
UpdateButtonPanel();
|
||||
MustRedraw |= RedrawButtonPanel | RedrawCursor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1426,7 +1396,6 @@ global void UIHandleButtonDown(unsigned button)
|
|||
if ((MouseButtons & LeftButton) &&
|
||||
TheUI.SelectedViewport != TheUI.MouseViewport) {
|
||||
TheUI.SelectedViewport = TheUI.MouseViewport;
|
||||
MustRedraw = RedrawMinimapCursor | RedrawMap;
|
||||
DebugLevel0Fn("selected viewport changed to %d.\n" _C_
|
||||
TheUI.SelectedViewport - TheUI.Viewports);
|
||||
}
|
||||
|
@ -1484,7 +1453,6 @@ global void UIHandleButtonDown(unsigned button)
|
|||
TileSizeY * TheUI.MouseViewport->MapY;
|
||||
GameCursor = TheUI.Cross.Cursor;
|
||||
CursorState = CursorStateRectangle;
|
||||
MustRedraw |= RedrawCursor;
|
||||
} else if (MouseButtons & MiddleButton) {// enter move map mode
|
||||
CursorStartX = CursorX;
|
||||
CursorStartY = CursorY;
|
||||
|
@ -1492,7 +1460,6 @@ global void UIHandleButtonDown(unsigned button)
|
|||
SubScrollY = 0;
|
||||
GameCursor = TheUI.Scroll.Cursor;
|
||||
DebugLevel3("Cursor middle down %d,%d\n" _C_ CursorX _C_ CursorY);
|
||||
MustRedraw |= RedrawCursor;
|
||||
} else if (MouseButtons & RightButton) {
|
||||
if (!GameObserve && !GamePaused) {
|
||||
Unit* unit;
|
||||
|
@ -1559,12 +1526,10 @@ global void UIHandleButtonDown(unsigned button)
|
|||
!GameMenuButtonClicked) {
|
||||
PlayGameSound(GameSounds.Click.Sound, MaxSampleVolume);
|
||||
GameMenuButtonClicked = 1;
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
} else if (ButtonUnderCursor == ButtonUnderNetworkDiplomacy &&
|
||||
!GameDiplomacyButtonClicked) {
|
||||
PlayGameSound(GameSounds.Click.Sound, MaxSampleVolume);
|
||||
GameDiplomacyButtonClicked = 1;
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
}
|
||||
//
|
||||
// clicked on selected button
|
||||
|
@ -1684,7 +1649,6 @@ global void UIHandleButtonUp(unsigned button)
|
|||
//
|
||||
if ((1 << button) == LeftButton && GameMenuButtonClicked) {
|
||||
GameMenuButtonClicked = 0;
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
if (ButtonAreaUnderCursor == ButtonAreaMenu &&
|
||||
(ButtonUnderCursor == ButtonUnderMenu ||
|
||||
ButtonUnderCursor == ButtonUnderNetworkMenu)) {
|
||||
|
@ -1703,7 +1667,6 @@ global void UIHandleButtonUp(unsigned button)
|
|||
//
|
||||
if ((1 << button) == LeftButton && GameDiplomacyButtonClicked) {
|
||||
GameDiplomacyButtonClicked = 0;
|
||||
MustRedraw |= RedrawMenuButton;
|
||||
if (ButtonAreaUnderCursor == ButtonAreaMenu &&
|
||||
ButtonUnderCursor == ButtonUnderNetworkDiplomacy) {
|
||||
// FIXME: Not if, in input mode.
|
||||
|
@ -1867,7 +1830,6 @@ global void UIHandleButtonUp(unsigned button)
|
|||
CursorStartY = 0;
|
||||
GameCursor = TheUI.Point.Cursor;
|
||||
CursorState = CursorStatePoint;
|
||||
MustRedraw |= RedrawCursor | RedrawMap | RedrawPanels;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3662,7 +3662,6 @@ local int CclDefineButton(lua_State* l)
|
|||
global void SelectionChanged(void)
|
||||
{
|
||||
UpdateButtonPanel();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -395,9 +395,6 @@ global void AssignUnitToPlayer(Unit* unit, Player* player)
|
|||
|
||||
if (type->Demand) {
|
||||
player->Demand += type->Demand; // food needed
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources; // update food
|
||||
}
|
||||
}
|
||||
// Don't Add the building if it's dieing, used to load a save game
|
||||
if (type->Building && unit->Orders[0].Action != UnitActionDie) {
|
||||
|
@ -516,7 +513,6 @@ global void PlaceUnit(Unit* unit, int x, int y)
|
|||
UnitCacheInsert(unit);
|
||||
|
||||
MustRedraw |= RedrawMinimap;
|
||||
CheckUnitToBeDrawn(unit);
|
||||
UnitCountSeen(unit);
|
||||
}
|
||||
|
||||
|
@ -633,7 +629,6 @@ global void RemoveUnit(Unit* unit, Unit* host)
|
|||
if (NumSelected == 1) { // Remove building cursor
|
||||
CancelBuildingMode();
|
||||
}
|
||||
MustRedraw |= RedrawPanels;
|
||||
UnSelectUnit(unit);
|
||||
SelectionChanged();
|
||||
}
|
||||
|
@ -680,7 +675,6 @@ global void RemoveUnit(Unit* unit, Unit* host)
|
|||
}
|
||||
|
||||
MustRedraw |= RedrawMinimap;
|
||||
CheckUnitToBeDrawn(unit);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -745,10 +739,6 @@ global void UnitLost(Unit* unit)
|
|||
//
|
||||
if (type->Demand) {
|
||||
player->Demand -= type->Demand;
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources; // update food
|
||||
// FIXME: MustRedraw |= RedrawFood;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -757,10 +747,6 @@ global void UnitLost(Unit* unit)
|
|||
if (unit->Orders[0].Action != UnitActionBuilded) {
|
||||
if (type->Supply) {
|
||||
player->Supply -= type->Supply;
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources;
|
||||
// FIXME: MustRedraw |= RedrawFood;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -780,9 +766,6 @@ global void UnitLost(Unit* unit)
|
|||
}
|
||||
}
|
||||
player->Incomes[i] = m;
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -858,9 +841,6 @@ global void UpdateForNewUnit(const Unit* unit, int upgrade)
|
|||
//
|
||||
if (type->Supply && !upgrade) {
|
||||
player->Supply += type->Supply;
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources; // update food
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -869,9 +849,6 @@ global void UpdateForNewUnit(const Unit* unit, int upgrade)
|
|||
for (u = 1; u < MaxCosts; ++u) {
|
||||
if (player->Incomes[u] < unit->Type->ImproveIncomes[u]) {
|
||||
player->Incomes[u] = unit->Type->ImproveIncomes[u];
|
||||
if (player == ThisPlayer) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1364,21 +1341,6 @@ global void GetUnitMapArea(const Unit* unit, int* sx, int* sy, int* ex, int* ey)
|
|||
*ey = *sy + unit->Type->TileHeight - !unit->IY;
|
||||
}
|
||||
|
||||
/**
|
||||
** Check and sets if unit must be drawn on screen-map
|
||||
**
|
||||
** @param unit Unit to be checked.
|
||||
** @return True if map marked to be drawn, false otherwise.
|
||||
*/
|
||||
global int CheckUnitToBeDrawn(Unit* unit)
|
||||
{
|
||||
if (UnitVisibleOnScreen(unit)) {
|
||||
MustRedraw |= RedrawMap;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Change the unit's owner
|
||||
**
|
||||
|
@ -1448,9 +1410,6 @@ global void ChangeUnitOwner(Unit* unit, Player* newplayer)
|
|||
}
|
||||
newplayer->Demand += unit->Type->Demand;
|
||||
newplayer->Supply += unit->Type->Supply;
|
||||
if (newplayer == ThisPlayer) {
|
||||
MustRedraw |= RedrawResources;// update food
|
||||
}
|
||||
if (unit->Type->Building) {
|
||||
newplayer->NumBuildings++;
|
||||
}
|
||||
|
|
|
@ -1163,8 +1163,6 @@ local void ConvertUnitTypeTo(Player* player, const UnitType* src, UnitType* dst)
|
|||
MapMarkUnitSight(unit);
|
||||
}
|
||||
player->UnitTypesCount[dst->Slot]++;
|
||||
|
||||
CheckUnitToBeDrawn(unit);
|
||||
//
|
||||
// Convert trained units to this type.
|
||||
// FIXME: what about buildings?
|
||||
|
@ -1172,12 +1170,9 @@ local void ConvertUnitTypeTo(Player* player, const UnitType* src, UnitType* dst)
|
|||
} else {
|
||||
if (unit->Orders[0].Action == UnitActionTrain) {
|
||||
for (j = 0; j < unit->Data.Train.Count; ++j) {
|
||||
if (unit->Data.Train.What[j] == src) {
|
||||
if (unit->Data.Train.What[j] == src) {
|
||||
unit->Data.Train.What[j] = dst;
|
||||
if (IsOnlySelected(unit)) {
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (j = 1; j < unit->OrderCount; ++j) {
|
||||
|
@ -1308,7 +1303,6 @@ global void UpgradeAcquire(Player* player, const Upgrade* upgrade)
|
|||
//
|
||||
if (player == ThisPlayer) {
|
||||
SelectedUnitChanged();
|
||||
MustRedraw |= RedrawInfoPanel;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,94 +104,8 @@ global UnitType* CursorBuilding; /// building cursor
|
|||
|
||||
|
||||
/*--- DRAW SPRITE CURSOR ---------------------------------------------------*/
|
||||
// Saved area after draw cursor, needed later to hide it again
|
||||
// (OldCursorW!=0 denotes it's defined)
|
||||
local int OldCursorInvalidate; /// flag (0/1): if cursor need invalidate
|
||||
local int OldCursorX; /// saved cursor position on screen X
|
||||
local int OldCursorY; /// saved cursor position on screen Y
|
||||
local int OldCursorW; /// saved cursor width in pixel
|
||||
local int OldCursorH; /// saved cursor height in pixel
|
||||
global CursorType* GameCursor; /// current shown cursor-type
|
||||
|
||||
// Area which is already hidden, but needed for invalidate
|
||||
// (HiddenCursorW!=0 denotes it's defined)
|
||||
local int HiddenCursorX; /// saved cursor position on screen X
|
||||
local int HiddenCursorY; /// saved cursor position on screen Y
|
||||
local int HiddenCursorW; /// saved cursor width in pixel
|
||||
local int HiddenCursorH; /// saved cursor height in pixel
|
||||
|
||||
/// Memory re-use, so can be defined although no save present!
|
||||
local int OldCursorSize; /// size of saved cursor image
|
||||
local SDL_Surface* OldCursorImage; /// background saved behind cursor
|
||||
|
||||
/**
|
||||
** Function pointer: Save 2D image behind sprite cursor
|
||||
**
|
||||
** @param x Screen X pixels coordinate for left-top corner.
|
||||
** @param y Screen Y pixels coordinate for left-top corner.
|
||||
** @param w Width in pixels for image starting at left-top.
|
||||
** @param h Height in pixels for image starting at left-top.
|
||||
**
|
||||
** @note the complete image should be in TheScreen (no clipping) and non-empty
|
||||
** (x >= 0, y >= 0, w > 0, h > 0, (x + w - 1) <= VideoWidth, (y + h - 1) <= VideoHeight)
|
||||
*/
|
||||
#ifndef USE_OPENGL
|
||||
local void SaveCursorBackground(int x, int y, int w, int h);
|
||||
/// Function pointer: Load background behind cursor
|
||||
local void LoadCursorBackground(int x, int y, int w, int h);
|
||||
#else
|
||||
#define LoadCursorBackground(x, y, w, h) // nothing
|
||||
#define SaveCursorBackground(x, y, w, h) // nothing
|
||||
#endif
|
||||
|
||||
/*--- DRAW RECTANGLE CURSOR ------------------------------------------------*/
|
||||
// Saved area after draw rectangle, needed later to hide it again
|
||||
// (OldCursorRectangleW != 0 denotes it's defined)
|
||||
local int OldCursorRectangleInvalidate; /// flag (0/1): ..need invalidate
|
||||
local int OldCursorRectangleX; /// saved cursor position on screen X
|
||||
local int OldCursorRectangleY; /// saved cursor position on screen Y
|
||||
local int OldCursorRectangleW; /// saved cursor width in pixel
|
||||
local int OldCursorRectangleH; /// saved cursor height in pixel
|
||||
local void* OldCursorRectangle; /// background saved behind rectangle
|
||||
|
||||
// Area which is already hidden, but needed for invalidate
|
||||
// (HiddenCursorRectangleW != 0 denotes it's defined)
|
||||
local int HiddenCursorRectangleX; /// saved cursor position on screen X
|
||||
local int HiddenCursorRectangleY; /// saved cursor position on screen Y
|
||||
local int HiddenCursorRectangleW; /// saved cursor width in pixel
|
||||
local int HiddenCursorRectangleH; /// saved cursor height in pixel
|
||||
|
||||
/**
|
||||
** Function pointer: Save rectangle behind cursor
|
||||
**
|
||||
** @param buffer Buffer in which the graphic is stored.
|
||||
** @param x Screen X pixels coordinate for left-top corner.
|
||||
** @param y Screen Y pixels coordinate for left-top corner.
|
||||
** @param w Width in pixels for rectangle starting at left-top.
|
||||
** @param h Height in pixels for rectangle starting at left-top.
|
||||
**
|
||||
** @note the complete rectangle should be in TheScreen (no clipping) and non-empty
|
||||
** (x >= 0, y >= 0, w > 0, h > 0, (x + w - 1) <= VideoWidth, (y + h - 1) <= VideoHeight)
|
||||
*/
|
||||
#ifndef USE_OPENGL
|
||||
global void SaveCursorRectangle(void* buffer, int x, int y, int w, int h);
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Function pointer: Load rectangle behind cursor
|
||||
**
|
||||
** @param buffer Buffer in which the graphic is stored.
|
||||
** @param x Screen X pixels coordinate.
|
||||
** @param y Screen Y pixels coordinate.
|
||||
** @param w Width in pixels.
|
||||
** @param h Height in pixels.
|
||||
**
|
||||
** @note rectangle previously saved with SaveCursorRectangle(x,y,w,h)
|
||||
*/
|
||||
#ifndef USE_OPENGL
|
||||
global void LoadCursorRectangle(void* buffer, int x, int y, int w, int h);
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- Functions
|
||||
----------------------------------------------------------------------------*/
|
||||
|
@ -269,73 +183,8 @@ global CursorType* CursorTypeByIdent(const char* ident)
|
|||
-- DRAW RECTANGLE CURSOR
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef USE_OPENGL
|
||||
global void LoadCursorRectangle(void* buffer, int x, int y, int w, int h)
|
||||
{
|
||||
int i;
|
||||
int bpp;
|
||||
char* sp;
|
||||
|
||||
bpp = TheScreen->format->BytesPerPixel;
|
||||
|
||||
VideoLockScreen();
|
||||
|
||||
sp = buffer;
|
||||
memcpy(&((unsigned char*)TheScreen->pixels)
|
||||
[x * bpp + y * TheScreen->pitch], sp, w * bpp);
|
||||
if (--h) {
|
||||
sp += w * bpp;
|
||||
memcpy(&((unsigned char*)TheScreen->pixels)
|
||||
[x * bpp + (y + h) * TheScreen->pitch], sp, w * bpp);
|
||||
sp += w * bpp;
|
||||
for (i = 1; i < h; ++i) {
|
||||
memcpy(&((unsigned char*)TheScreen->pixels)
|
||||
[x * bpp + (y + i) * TheScreen->pitch], sp, bpp);
|
||||
memcpy(&((unsigned char*)TheScreen->pixels)
|
||||
[(x + w - 1) * bpp + (y + i) * TheScreen->pitch],
|
||||
sp + bpp, bpp);
|
||||
sp += bpp * 2;
|
||||
}
|
||||
}
|
||||
|
||||
VideoUnlockScreen();
|
||||
}
|
||||
|
||||
global void SaveCursorRectangle(void* buffer, int x, int y, int w, int h)
|
||||
{
|
||||
int i;
|
||||
int bpp;
|
||||
char* dp;
|
||||
|
||||
bpp = TheScreen->format->BytesPerPixel;
|
||||
|
||||
VideoLockScreen();
|
||||
|
||||
dp = buffer;
|
||||
memcpy(dp, &((unsigned char*)TheScreen->pixels)
|
||||
[x * bpp + y * TheScreen->pitch], w * bpp);
|
||||
if (--h) {
|
||||
dp += w * bpp;
|
||||
memcpy(dp, &((unsigned char*)TheScreen->pixels)
|
||||
[x * bpp + (y + h) * TheScreen->pitch], w * bpp);
|
||||
dp += w * bpp;
|
||||
for (i = 1; i < h; ++i) {
|
||||
memcpy(dp, &((unsigned char*)TheScreen->pixels)
|
||||
[x * bpp + (y + i) * TheScreen->pitch], bpp);
|
||||
memcpy(dp + bpp, &((unsigned char*)TheScreen->pixels)
|
||||
[(x + w - 1) * bpp + (y + i) * TheScreen->pitch], bpp);
|
||||
dp += bpp * 2;
|
||||
}
|
||||
}
|
||||
|
||||
VideoUnlockScreen();
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Draw rectangle cursor when visible, defined by
|
||||
** OldCursorRectangleW (!=0),..
|
||||
** Pre: for this to work OldCursorRectangleW should be 0 upfront
|
||||
** Draw rectangle cursor when visible
|
||||
**
|
||||
** @param x Screen x start position of rectangle
|
||||
** @param y Screen y start position of rectangle
|
||||
|
@ -378,63 +227,15 @@ local void DrawVisibleRectangleCursor(int x, int y, int x1, int y1)
|
|||
}
|
||||
|
||||
if (w && h) {
|
||||
SaveCursorRectangle(OldCursorRectangle,
|
||||
OldCursorRectangleX = x, OldCursorRectangleY = y,
|
||||
OldCursorRectangleW = w, OldCursorRectangleH = h);
|
||||
VideoDrawRectangleClip(ColorGreen, x, y, w, h);
|
||||
OldCursorRectangleInvalidate = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
-- DRAW SPRITE CURSOR
|
||||
----------------------------------------------------------------------------*/
|
||||
#ifndef USE_OPENGL
|
||||
local void LoadCursorBackground(int x, int y, int w, int h)
|
||||
{
|
||||
SDL_Rect drect;
|
||||
SDL_Rect srect;
|
||||
|
||||
srect.x = 0;
|
||||
srect.y = 0;
|
||||
srect.w = w;
|
||||
srect.h = h;
|
||||
|
||||
drect.x = x;
|
||||
drect.y = y;
|
||||
|
||||
SDL_BlitSurface(OldCursorImage, &srect, TheScreen, &drect);
|
||||
}
|
||||
|
||||
local void SaveCursorBackground(int x, int y, int w, int h)
|
||||
{
|
||||
SDL_Rect srect;
|
||||
|
||||
srect.x = x;
|
||||
srect.y = y;
|
||||
srect.w = w;
|
||||
srect.h = h;
|
||||
|
||||
SDL_BlitSurface(TheScreen, &srect, OldCursorImage, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Destroy image behind cursor.
|
||||
*/
|
||||
global void DestroyCursorBackground(void)
|
||||
{
|
||||
if (OldCursorImage) {
|
||||
SDL_FreeSurface(OldCursorImage);
|
||||
OldCursorImage = NULL;
|
||||
}
|
||||
OldCursorSize = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
** Draw (sprite) cursor when visible, defined by
|
||||
** OldCursorW (!=0),..
|
||||
** Pre: for this to work OldCursorW should be 0 upfront
|
||||
** Draw (sprite) cursor
|
||||
**
|
||||
** @param type Cursor-type of the cursor to draw.
|
||||
** @param x Screen x pixel position.
|
||||
|
@ -443,35 +244,7 @@ global void DestroyCursorBackground(void)
|
|||
*/
|
||||
local void DrawCursor(const CursorType* type, int x, int y, int frame)
|
||||
{
|
||||
int size;
|
||||
int w;
|
||||
int h;
|
||||
int spritex;
|
||||
int spritey;
|
||||
|
||||
DebugCheck(!type);
|
||||
//
|
||||
// Save cursor position and size, for faster cursor redraw.
|
||||
//
|
||||
spritex = (x -= type->HotX);
|
||||
spritey = (y -= type->HotY);
|
||||
w = VideoGraphicWidth(type->Sprite);
|
||||
h = VideoGraphicHeight(type->Sprite);
|
||||
|
||||
// Reserve enough memory for background of sprite (also for future calls)
|
||||
size = w * h;
|
||||
if (OldCursorSize < size) {
|
||||
OldCursorImage = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, BMASK, GMASK, RMASK, AMASK);
|
||||
OldCursorSize = size;
|
||||
}
|
||||
// Save (seen) area behind sprite
|
||||
CLIP_RECTANGLE(x, y, w, h);
|
||||
SaveCursorBackground(OldCursorX = x, OldCursorY = y,
|
||||
OldCursorW = w, OldCursorH = h);
|
||||
|
||||
// Draw sprite (using its own clipping) FIXME: prevent clipping twice
|
||||
VideoDrawClip(type->Sprite, frame, spritex, spritey);
|
||||
OldCursorInvalidate = 1;
|
||||
VideoDrawClip(type->Sprite, frame, x - type->HotX, y - type->HotY);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
@ -583,10 +356,6 @@ local void DrawBuildingCursor(void)
|
|||
*/
|
||||
global void DrawAnyCursor(void)
|
||||
{
|
||||
// Disable any previous drawn cursor
|
||||
OldCursorInvalidate = OldCursorW = OldCursorRectangleInvalidate =
|
||||
OldCursorRectangleW = BuildingCursor = 0;
|
||||
|
||||
//
|
||||
// First, Selecting rectangle
|
||||
//
|
||||
|
@ -603,7 +372,6 @@ global void DrawAnyCursor(void)
|
|||
|
||||
//
|
||||
// Last, Normal cursor.
|
||||
// This will also save (part of) drawn rectangle cursor, but that's ok.
|
||||
// Cursor May not Exist if we are loading a game or something. Only
|
||||
// draw it if it exists
|
||||
//
|
||||
|
@ -612,61 +380,6 @@ global void DrawAnyCursor(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Remove old cursor from display.
|
||||
** (in the opposite direction of DrawAnyCursor)
|
||||
** Note: this function can be called, without calling DrawAnyCursor first,
|
||||
** which means that cursors shouldn't be restored twice.
|
||||
** As cursors are, like DrawAnyCursor, not invalidated here, it
|
||||
** still needs to be done by InvalidateCursorAreas.
|
||||
*/
|
||||
global void HideAnyCursor(void)
|
||||
{
|
||||
//
|
||||
// First, Normal cursor (might restore part of rectangle cursor also).
|
||||
//
|
||||
if (OldCursorW && OldCursorImage) {
|
||||
// restore area of visible cursor
|
||||
LoadCursorBackground(OldCursorX, OldCursorY, OldCursorW, OldCursorH);
|
||||
|
||||
// save hidden area to be invalidated
|
||||
HiddenCursorX = OldCursorX;
|
||||
HiddenCursorY = OldCursorY;
|
||||
HiddenCursorW = OldCursorW;
|
||||
HiddenCursorH = OldCursorH;
|
||||
|
||||
// Denote cursor no longer visible
|
||||
OldCursorW = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Last, Selecting rectangle
|
||||
//
|
||||
if (OldCursorRectangleW) {
|
||||
// restore area of visible cursor
|
||||
LoadCursorRectangle(OldCursorRectangle,
|
||||
OldCursorRectangleX, OldCursorRectangleY,
|
||||
OldCursorRectangleW, OldCursorRectangleH);
|
||||
|
||||
// save hidden area to be invalidated
|
||||
HiddenCursorRectangleX = OldCursorRectangleX;
|
||||
HiddenCursorRectangleY = OldCursorRectangleY;
|
||||
HiddenCursorRectangleW = OldCursorRectangleW;
|
||||
HiddenCursorRectangleH = OldCursorRectangleH;
|
||||
|
||||
// Denote cursor no longer visible
|
||||
OldCursorRectangleW = 0;
|
||||
} else if (BuildingCursor) {
|
||||
//
|
||||
// Or Selecting position for building
|
||||
//
|
||||
// NOTE: this will restore tiles themselves later in next video update
|
||||
MarkDrawAreaMap(BuildingCursorSX, BuildingCursorSY,
|
||||
BuildingCursorEX, BuildingCursorEY);
|
||||
BuildingCursor = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Animate the cursor.
|
||||
**
|
||||
|
@ -686,143 +399,14 @@ global void CursorAnimate(unsigned ticks)
|
|||
VideoGraphicFrames(GameCursor->Sprite)) {
|
||||
GameCursor->SpriteFrame = 0;
|
||||
}
|
||||
MustRedraw |= RedrawCursor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Let an area be invalidated, but remembering if cursor is automaticly
|
||||
** invalidated with this area.
|
||||
** Note: building-cursor is already invalidated by redraw-map
|
||||
**
|
||||
** @param x left-top x-position of area on screen
|
||||
** @param y left-top y-position of area on screen
|
||||
** @param w width of area on screen
|
||||
** @param h height of area on screen
|
||||
*/
|
||||
global void InvalidateAreaAndCheckCursor(int x, int y, int w, int h)
|
||||
{
|
||||
int dx;
|
||||
int dy;
|
||||
|
||||
// Invalidate area
|
||||
InvalidateArea(x, y, w, h);
|
||||
|
||||
// Now check if cursor sprite is inside it, then no need for invalidate
|
||||
if (OldCursorInvalidate) {
|
||||
dx = OldCursorX - x;
|
||||
dy = OldCursorY - y;
|
||||
if (dx >= 0 && dy >= 0 && (w - dx) >= OldCursorW &&
|
||||
(h - dy) >= OldCursorH) {
|
||||
OldCursorInvalidate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Now check if previously hidden cursor sprite is inside it..
|
||||
if (HiddenCursorW) {
|
||||
dx = HiddenCursorX - x;
|
||||
dy = HiddenCursorY - y;
|
||||
if (dx >= 0 && dy >= 0 && (w - dx) >= HiddenCursorW &&
|
||||
(h - dy) >= HiddenCursorH) {
|
||||
HiddenCursorW = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Now check if cursor rectangle is inside it..
|
||||
if (OldCursorRectangleInvalidate) {
|
||||
dx = OldCursorRectangleX - x;
|
||||
dy = OldCursorRectangleY - y;
|
||||
if (dx >= 0 && dy >= 0 && (w - dx) >= OldCursorRectangleW &&
|
||||
(h - dy) >= OldCursorRectangleH) {
|
||||
OldCursorRectangleInvalidate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Now check if previously hidden cursor rectangle is inside it..
|
||||
if (HiddenCursorRectangleW) {
|
||||
dx = HiddenCursorRectangleX - x;
|
||||
dy = HiddenCursorRectangleY - y;
|
||||
if (dx >= 0 && dy >= 0 && (w - dx) >= HiddenCursorRectangleW &&
|
||||
(h - dy) >= HiddenCursorRectangleH) {
|
||||
HiddenCursorRectangleW = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Invalidate only the sides of a given rectangle (not its contents)
|
||||
**
|
||||
** @param x left-top x-position of rectangle on screen
|
||||
** @param y left-top y-position of rectangle on screen
|
||||
** @param w width of rectangle on screen
|
||||
** @param h height of rectangle on screen
|
||||
*/
|
||||
local void InvalidateRectangle(int x, int y, int w, int h)
|
||||
{
|
||||
InvalidateArea(x, y, w, 1); // top side
|
||||
if (--h > 0) {
|
||||
InvalidateArea(x, y + h, w, 1); // bottom side
|
||||
if (--h > 0) {
|
||||
InvalidateArea(x, ++y, 1, h); // left side
|
||||
if (--w > 0) {
|
||||
InvalidateArea(x + w, y, 1, h); // right side
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Let the (remaining) areas taken by the cursors, as determined by
|
||||
** DrawAnyCursor and InvalidateAreaAndCheckcursor, be invalidated.
|
||||
** Note: building-cursor is already invalidated by redraw-map
|
||||
*/
|
||||
global void InvalidateCursorAreas(void)
|
||||
{
|
||||
// Invalidate cursor sprite
|
||||
if (OldCursorInvalidate) {
|
||||
InvalidateArea(OldCursorX, OldCursorY, OldCursorW, OldCursorH);
|
||||
OldCursorInvalidate = 0;
|
||||
}
|
||||
|
||||
// Invalidate hidden cursor sprite
|
||||
if (HiddenCursorW) {
|
||||
InvalidateArea(HiddenCursorX, HiddenCursorY, HiddenCursorW, HiddenCursorH);
|
||||
HiddenCursorW = 0;
|
||||
}
|
||||
|
||||
// Invalidate cursor rectangle
|
||||
if (OldCursorRectangleInvalidate) {
|
||||
InvalidateRectangle(OldCursorRectangleX, OldCursorRectangleY,
|
||||
OldCursorRectangleW, OldCursorRectangleH);
|
||||
OldCursorRectangleInvalidate = 0;
|
||||
}
|
||||
|
||||
// Invalidate hidden cursor rectangle
|
||||
if (HiddenCursorRectangleW) {
|
||||
InvalidateRectangle(HiddenCursorRectangleX, HiddenCursorRectangleY,
|
||||
HiddenCursorRectangleW, HiddenCursorRectangleH);
|
||||
HiddenCursorRectangleW = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
** Setup the cursor part.
|
||||
**
|
||||
** @todo FIXME: Now max possible memory for OldCursorRectangle,
|
||||
** to be limited to Map?
|
||||
*/
|
||||
global void InitVideoCursors(void)
|
||||
{
|
||||
#ifndef USE_OPENGL
|
||||
// memory of possible previous video-setting?
|
||||
if (OldCursorRectangle) {
|
||||
free(OldCursorRectangle);
|
||||
OldCursorRectangle = 0;
|
||||
}
|
||||
OldCursorRectangle = malloc((2 * VideoWidth + 2 *
|
||||
(VideoHeight - 2)) * TheScreen->format->BytesPerPixel);
|
||||
#endif
|
||||
|
||||
CursorX = VideoWidth / 2;
|
||||
CursorY = VideoHeight / 2;
|
||||
}
|
||||
|
@ -842,11 +426,6 @@ global void CleanCursors(void)
|
|||
free(Cursors);
|
||||
Cursors = NULL;
|
||||
|
||||
free(OldCursorRectangle);
|
||||
OldCursorRectangle = 0;
|
||||
|
||||
DestroyCursorBackground();
|
||||
|
||||
CursorBuilding = 0;
|
||||
GameCursor = 0;
|
||||
UnitUnderCursor = NoUnitP;
|
||||
|
|
|
@ -533,7 +533,6 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
TheUI.MouseWarpY = -1;
|
||||
SDL_WarpMouse(xw, yw);
|
||||
}
|
||||
MustRedraw |= RedrawCursor;
|
||||
break;
|
||||
|
||||
case SDL_ACTIVEEVENT:
|
||||
|
@ -556,7 +555,6 @@ local void SdlDoEvent(const EventCallback* callbacks, const SDL_Event* event)
|
|||
} else if (!IsVisible && event->active.gain) {
|
||||
IsVisible = 1;
|
||||
UiTogglePause();
|
||||
MustRedraw = RedrawEverything & ~RedrawMinimap;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -713,12 +711,12 @@ global void RealizeVideoMemory(void)
|
|||
#ifdef USE_OPENGL
|
||||
SDL_GL_SwapBuffers();
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
MustRedraw = RedrawEverything;
|
||||
#else
|
||||
if (NumRects) {
|
||||
SDL_UpdateRects(TheScreen, NumRects, Rects);
|
||||
NumRects = 0;
|
||||
}
|
||||
VideoClearScreen();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -460,8 +460,6 @@ global void ColorCycle(void)
|
|||
SDL_SetPalette(TheMap.TileGraphic->Surface, SDL_LOGPAL | SDL_PHYSPAL,
|
||||
colors, 0, 256);
|
||||
}
|
||||
|
||||
MustRedraw |= RedrawColorCycle;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
|
|
@ -836,10 +836,6 @@ SOURCE=.\src\include\cursor.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\include\deco.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\include\depend.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -940,14 +936,6 @@ SOURCE=.\src\include\settings.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\include\siod.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\include\siodp.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\include\sound.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
Loading…
Add table
Reference in a new issue