Comments (14)
(by andre-ng)
I almost managed to implement this, but I can't get the game to remove the unpressed Frame when the pressed Frame is drawnβ. The code I'm using:
if (Preference.IconsShift && Preference.IconFrameG && Preference.PressedIconFrameG) {
if (!(flags & IconClicked)) {
Preference.IconFrameG->DrawClip(pos.x - 4, pos.y - 4);
}
if (flags & IconActive) { // Code to make a border appear around the icon when the mouse hovers over it.
Video.DrawRectangle(ColorGray, pos.x - 4, pos.y - 4, 54, 46);
DrawUIButton(&s, flags, pos.x, pos.y, text, player);
}
if (flags & IconClicked) { // Shift the icon a bit to make it look like it's been pressed.
DrawUIButton(&s, flags, pos.x + 1, pos.y + 1, text, player);
if (flags & IconSelected) {
Video.DrawRectangle(ColorGreen, pos.x + 1, pos.y + 1, 46, 38);
}
Preference.PressedIconFrameG->DrawClip(pos.x - 3, pos.y - 3);
Video.DrawRectangle(ColorGray, pos.x - 4, pos.y - 4, 54, 46);
} else {
DrawUIButton(&s, flags, pos.x, pos.y, text, player);
if (flags & IconSelected) {
Video.DrawRectangle(ColorGreen, pos.x, pos.y, 46, 38);
}
}
} else if (Preference.IconsShift) {
[...]
from stratagus.
(by andre-ng)
Changes in unit.h (CPreference):
class CPreference
{
public:
CPreference() : ShowSightRange(false), ShowReactionRange(false),
ShowAttackRange(false), ShowMessages(true), BigScreen(false),
PauseOnLeave(true), AiExplores(true), GrayscaleIcons(false),
IconsShift(false), StereoSound(true), MineNotifications(false),
DeselectInMine(false),
//Wyrmgus start
// ShowOrders(0), ShowNameDelay(0), ShowNameTime(0) {};
ShowOrders(0), ShowNameDelay(0), ShowNameTime(0),
IconFrameG(NULL), PressedIconFrameG(NULL) {};
//Wyrmgus end
bool ShowSightRange; /// Show sight range.
bool ShowReactionRange; /// Show reaction range.
bool ShowAttackRange; /// Show attack range.
bool ShowMessages; /// Show messages.
bool BigScreen; /// If true, shows the big screen(without panels)
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
bool StereoSound; /// Enables/disables stereo sound effects
bool MineNotifications; /// Show mine is running low/depleted messages
bool DeselectInMine; /// Deselect peasants in mines
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.
int ShowNameTime; /// How many cycles need to show unit's name popup.
std::string SF2Soundfont;/// Path to SF2 soundfont
//Wyrmgus start
CGraphic *IconFrameG;
CGraphic *PressedIconFrameG;
//Wyrmgus end
};
from stratagus.
(by andre-ng)
Changes in unit.pkg (CPreference):
class CPreference
{
bool ShowSightRange;
bool ShowReactionRange;
bool ShowAttackRange;
bool ShowMessages;
bool BigScreen;
bool PauseOnLeave;
bool AiExplores;
bool GrayscaleIcons;
bool IconsShift;
bool StereoSound;
bool MineNotifications;
bool DeselectInMine;
unsigned int ShowOrders;
unsigned int ShowNameDelay;
unsigned int ShowNameTime;
std::string SF2Soundfont;
//Wyrmgus start
CGraphic *IconFrameG;
CGraphic *PressedIconFrameG;
//Wyrmgus end
};
from stratagus.
(by andre-ng)
Changes in ui.cpp (CUserInterface::Load()):
void CUserInterface::Load()
{
// Load graphics
const int size = (int)Fillers.size();
for (int i = 0; i < size; ++i) {
Fillers[i].Load();
}
for (int i = 0; i <= FreeWorkersCount; ++i) {
if (Resources[i].G) {
Resources[i].G->Load();
Resources[i].G->UseDisplayFormat();
}
}
if (InfoPanel.G) {
InfoPanel.G->Load();
InfoPanel.G->UseDisplayFormat();
}
if (ButtonPanel.G) {
ButtonPanel.G->Load();
ButtonPanel.G->UseDisplayFormat();
}
if (PieMenu.G) {
PieMenu.G->Load();
PieMenu.G->UseDisplayFormat();
}
//Wyrmgus start
if (Preference.IconFrameG) {
Preference.IconFrameG->Load();
Preference.IconFrameG->UseDisplayFormat();
}
if (Preference.PressedIconFrameG) {
Preference.PressedIconFrameG->Load();
Preference.PressedIconFrameG->UseDisplayFormat();
}
//Wyrmgus end
// Resolve cursors
Point.Load();
Glass.Load();
Cross.Load();
YellowHair.Load();
GreenHair.Load();
RedHair.Load();
Scroll.Load();
ArrowE.Load();
ArrowNE.Load();
ArrowN.Load();
ArrowNW.Load();
ArrowW.Load();
ArrowSW.Load();
ArrowS.Load();
ArrowSE.Load();
}
from stratagus.
(by andre-ng)
Changes in ui.cpp (CleanUserInterface()):
void CleanUserInterface()
{
// Filler
for (int i = 0; i < (int)UI.Fillers.size(); ++i) {
CGraphic::Free(UI.Fillers[i].G);
}
UI.Fillers.clear();
// Resource Icons
for (int i = 0; i <= FreeWorkersCount; ++i) {
CGraphic::Free(UI.Resources[i].G);
}
// Info Panel
CGraphic::Free(UI.InfoPanel.G);
for (std::vector<CUnitInfoPanel *>::iterator panel = UI.InfoPanelContents.begin();
panel != UI.InfoPanelContents.end(); ++panel) {
delete *panel;
}
UI.InfoPanelContents.clear();
//Wyrmgus start
CGraphic::Free(Preference.IconFrameG);
CGraphic::Free(Preference.PressedIconFrameG);
//Wyrmgus end
// Button Popups
for (std::vector<CPopup *>::iterator popup = UI.ButtonPopups.begin();
popup != UI.ButtonPopups.end(); ++popup) {
delete *popup;
}
UI.ButtonPopups.clear();
delete UI.SingleSelectedButton;
UI.SelectedButtons.clear();
delete UI.SingleTrainingButton;
UI.SingleTrainingText.clear();
UI.TrainingButtons.clear();
UI.TrainingText.clear();
delete UI.UpgradingButton;
delete UI.ResearchingButton;
UI.TransportingButtons.clear();
UI.UserButtons.clear();
// Button Panel
CGraphic::Free(UI.ButtonPanel.G);
// Pie Menu
CGraphic::Free(UI.PieMenu.G);
// Backgrounds
CGraphic::Free(UI.VictoryBackgroundG);
CGraphic::Free(UI.DefeatBackgroundG);
// Title Screens
if (TitleScreens) {
for (int i = 0; TitleScreens[i]; ++i) {
delete TitleScreens[i];
}
delete[] TitleScreens;
TitleScreens = NULL;
}
}
from stratagus.
@Andrettin is this still something that would be useful? Is this available in Wyrmgus and should be ported?
from stratagus.
It is available in Wyrmgus, but the code might need some cleanup.
from stratagus.
Cool as guys I would love to see this implemented in Wargus/Stratagus. Do you if we had images as the borders, that it would be possible to have those images animate?
from stratagus.
Any more progress on this?
from stratagus.
I don't think I've ever integrated it into Stratagus, but it's fully functional in Wyrmgus.
from stratagus.
Ill do it :)
from stratagus.
OK so I got the code working for this in stratagus. Again by copying your code. Messy job I did but it works now for icons frame images yay!
One thing though, is the border around the icon in Wargus flashes grey...how do I/where do I edit to stop this in the code...Surely it's not in the scripts.
Everything else works as it should in relation to the icons. I'll update the trunk once I get help with the flashing border problem - yes problem, its an annoying and completely useless feature IMO.
Anyway thanks again Andrettin π You legend you π
from stratagus.
@DinkyDyeAussie I went ahead and included the code @Andrettin posted here in master. w.r.t. the flashing, if you want to get rid of the colored frame entirely, just define the button style for icons as fully black:
[...]
Hover = {
Border = {
[...]
Color={0,0,0}
}
}
Or, to get a solid color:
[...]
Hover = {
Border = {
[...]
SolidColor={128,128,128}
}
}
from stratagus.
Ended up doing this Tim. No more flashing :)
from stratagus.
Related Issues (20)
- [macOS] The Cmake HAS_17_FS test fails with Xcode 14.3 HOT 3
- ui/black_title.png not loading and crashing game
- custom UI artwork HOT 6
- Multiplayer on network won't allow non-host player to be Orc HOT 1
- Wargus 3.3.2 - Bug Extraction process HOT 5
- Wargus - Network out of sync in Single Player Campaign HOT 12
- building tolua.cpp.o: try to execute -L in sh HOT 1
- try to build with /usr/include/lua.h rather than /usr/include/lua-5.1/lua.h (I think) HOT 2
- Documentation typo/incorrect information? HOT 6
- Unexpected behavior when upgrading units to units with lower maximum health HOT 1
- Stratagus failed to load game data. HOT 1
- build stratagus make fatal error: mdns.h HOT 5
- Broken CI with icon with linuxdeploy HOT 2
- Network Desync. HOT 7
- Red Humans Glitch when loading games, followed by a Crash. (War1gus)
- crash on startup HOT 5
- PLEASE modify the uninstaller
- Warcraft 3 HOT 1
- [macOS] Regression: Black text on main menu in Wargus (Stratagus bug) HOT 5
- Crash to desktop when upgrading/morphing unit that is carrying resources into one that cannot
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stratagus.