Giter Site home page Giter Site logo

Icon Frame Images about stratagus HOT 14 CLOSED

wargus avatar wargus commented on May 23, 2024
Icon Frame Images

from stratagus.

Comments (14)

timfel avatar timfel commented on May 23, 2024

(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.

timfel avatar timfel commented on May 23, 2024

(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.

timfel avatar timfel commented on May 23, 2024

(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.

timfel avatar timfel commented on May 23, 2024

(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.

timfel avatar timfel commented on May 23, 2024

(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.

timfel avatar timfel commented on May 23, 2024

@Andrettin is this still something that would be useful? Is this available in Wyrmgus and should be ported?

from stratagus.

Andrettin avatar Andrettin commented on May 23, 2024

It is available in Wyrmgus, but the code might need some cleanup.

from stratagus.

DinkyDyeAussie avatar DinkyDyeAussie commented on May 23, 2024

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.

DinkyDyeAussie avatar DinkyDyeAussie commented on May 23, 2024

Any more progress on this?

from stratagus.

Andrettin avatar Andrettin commented on May 23, 2024

I don't think I've ever integrated it into Stratagus, but it's fully functional in Wyrmgus.

from stratagus.

DinkyDyeAussie avatar DinkyDyeAussie commented on May 23, 2024

Ill do it :)

from stratagus.

DinkyDyeAussie avatar DinkyDyeAussie commented on May 23, 2024

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.

timfel avatar timfel commented on May 23, 2024

@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.

DinkyDyeAussie avatar DinkyDyeAussie commented on May 23, 2024

Ended up doing this Tim. No more flashing :)

from stratagus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.