[*] Added CPreference::IconsShift, to shift icons slightly when you press on them

This commit is contained in:
cybermind 2014-05-30 22:59:30 +06:00
parent c5a56f0b7b
commit cacc4ce874
8 changed files with 53 additions and 7 deletions

View file

@ -1628,6 +1628,7 @@ static void EditorCallbackMouse(const PixelPos &pos)
Editor.CursorUnitIndex = -1;
Editor.CursorTileIndex = -1;
ButtonUnderCursor = -1;
OldButtonUnderCursor = -1;
// Minimap
if (UI.Minimap.Contains(screenPos)) {

View file

@ -230,6 +230,8 @@ extern CUnit *UnitUnderCursor;
extern int ButtonAreaUnderCursor;
/// button number under the cursor
extern int ButtonUnderCursor;
/// oldbutton number under the cursor
extern int OldButtonUnderCursor;
/// menu button was clicked down
extern bool GameMenuButtonClicked;
/// diplomacy button was clicked down

View file

@ -428,6 +428,7 @@ public:
CPreference() : ShowSightRange(false), ShowReactionRange(false),
ShowAttackRange(false), ShowMessages(true), BigScreen(false),
PauseOnLeave(true), AiExplores(true), GrayscaleIcons(false),
IconsShift(false),
ShowOrders(0), ShowNameDelay(0), ShowNameTime(0) {};
bool ShowSightRange; /// Show sight range.
@ -438,6 +439,7 @@ public:
bool PauseOnLeave; /// If true, game pauses when cursor is gone
bool AiExplores; /// If true, AI sends explorers to search for resources (almost useless thing)
bool GrayscaleIcons; /// Use grayscaled icons for unavailable units, upgrades, etc
bool IconsShift; /// Shift icons slightly when you press on them
int ShowOrders; /// How many second show orders of unit on map.
int ShowNameDelay; /// How many cycles need to wait until unit's name popup will appear.

View file

@ -279,6 +279,7 @@ static int MenuLoop()
Invalidate();
ButtonUnderCursor = -1;
OldButtonUnderCursor = -1;
CursorState = CursorStatePoint;
GameCursor = UI.Point.Cursor;

View file

@ -26,6 +26,7 @@ class CPreference
bool PauseOnLeave;
bool AiExplores;
bool GrayscaleIcons;
bool IconsShift;
unsigned int ShowOrders;
unsigned int ShowNameDelay;

View file

@ -279,10 +279,10 @@ static const CUnit *GetUnitRef(const CUnit &unit, EnumUnit e)
}
// Border
Video.FillRectangleClip(ColorBlack, this->Pos.x - 1, this->Pos.y - 1,
this->Width + 2, this->Height + 2);
Video.FillRectangleClip(ColorBlack, this->Pos.x - 2, this->Pos.y - 2,
this->Width + 3, this->Height + 3);
Video.FillRectangleClip(color, this->Pos.x, this->Pos.y,
Video.FillRectangleClip(color, this->Pos.x - 1, this->Pos.y - 1,
(f * this->Width) / 100, this->Height);
}

View file

@ -190,8 +190,30 @@ void CIcon::DrawUnitIcon(const ButtonStyle &style, unsigned flags,
s.Default.BorderColorRGB = UI.ButtonPanel.AutoCastBorderColorRGB;
s.Default.BorderColor = 0;
}
// FIXME: player colors
DrawUIButton(&s, flags, pos.x, pos.y, text, player);
if (Preference.IconsShift) {
// Left and top edge of Icon
Video.DrawHLine(ColorWhite, pos.x - 1, pos.y - 1, 49);
Video.DrawVLine(ColorWhite, pos.x - 1, pos.y, 40);
Video.DrawVLine(ColorWhite, pos.x, pos.y + 38, 2);
Video.DrawHLine(ColorWhite, pos.x + 46, pos.y, 2);
// Bottom and Right edge of Icon
Video.DrawHLine(ColorGray, pos.x + 1, pos.y + 38, 47);
Video.DrawHLine(ColorGray, pos.x + 1, pos.y + 39, 47);
Video.DrawVLine(ColorGray, pos.x + 46, pos.y + 1, 37);
Video.DrawVLine(ColorGray, pos.x + 47, pos.y + 1, 37);
Video.DrawRectangle(ColorBlack, pos.x - 3, pos.y - 3, 52, 44);
Video.DrawRectangle(ColorBlack, pos.x - 4, pos.y - 4, 54, 46);
if (flags & IconClicked) {
DrawUIButton(&s, flags, pos.x + 1, pos.y + 1, text, player);
} else {
DrawUIButton(&s, flags, pos.x, pos.y, text, player);
}
} else {
DrawUIButton(&s, flags, pos.x, pos.y, text, player);
}
}
/**

View file

@ -77,6 +77,7 @@ int KeyModifiers; /// Current keyboard modifiers
CUnit *UnitUnderCursor; /// Unit under cursor
int ButtonAreaUnderCursor = -1; /// Button area under cursor
int ButtonUnderCursor = -1; /// Button under cursor
int OldButtonUnderCursor = -1; /// Button under cursor
bool GameMenuButtonClicked; /// Menu button was clicked
bool GameDiplomacyButtonClicked; /// Diplomacy button was clicked
bool LeaveStops; /// Mouse leaves windows stops scroll
@ -644,6 +645,7 @@ static void HandleMouseOn(const PixelPos screenPos)
MouseScrollState = ScrollNone;
ButtonAreaUnderCursor = -1;
ButtonUnderCursor = -1;
OldButtonUnderCursor = -1;
// BigMapMode is the mode which show only the map (without panel, minimap)
if (BigMapMode) {
@ -1550,7 +1552,7 @@ static void UISelectStateButtonDown(unsigned)
if (CursorOn == CursorOnButton) {
// FIXME: other buttons?
if (ButtonAreaUnderCursor == ButtonAreaButton) {
UI.ButtonPanel.DoClicked(ButtonUnderCursor);
OldButtonUnderCursor = ButtonUnderCursor;
return;
}
}
@ -1753,7 +1755,7 @@ static void UIHandleButtonDown_OnButton(unsigned button)
}
} else if (ButtonAreaUnderCursor == ButtonAreaButton) {
if (!GameObserve && !GamePaused && !GameEstablishing && ThisPlayer->IsTeamed(*Selected[0])) {
UI.ButtonPanel.DoClicked(ButtonUnderCursor);
OldButtonUnderCursor = ButtonUnderCursor;
}
}
} else if ((MouseButtons & MiddleButton)) {
@ -1793,6 +1795,7 @@ void UIHandleButtonDown(unsigned button)
static bool OldShowReactionRange;
static bool OldShowAttackRange;
static bool OldValid = false;
OldButtonUnderCursor = -1;
// Reset the ShowNameDelay counters
ShowNameDelay = ShowNameTime = GameCycle;
@ -1933,6 +1936,20 @@ void UIHandleButtonUp(unsigned button)
}
}
}
if (!GameObserve && !GamePaused && !GameEstablishing && Selected.empty() == false && ThisPlayer->IsTeamed(*Selected[0])) {
if (OldButtonUnderCursor != -1 && OldButtonUnderCursor == ButtonUnderCursor) {
UI.ButtonPanel.DoClicked(ButtonUnderCursor);
OldButtonUnderCursor = -1;
return;
}
}
if (CursorOn == CursorOnButton) {
// FIXME: other buttons?
if (ButtonAreaUnderCursor == ButtonAreaButton && OldButtonUnderCursor != -1 && OldButtonUnderCursor == ButtonUnderCursor) {
UI.ButtonPanel.DoClicked(ButtonUnderCursor);
return;
}
}
}
// FIXME: should be completly rewritten