Icon Frame Images

Bug #1428597 reported by Andre Novellino Gouvêa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stratagus
Won't Fix
Wishlist
cybermind

Bug Description

Not a bug, but a wishlist item. It would be nice to be able to set an image as a frame icon with IconsShift, replacing the frame drawn by the engine if such an image is set.

Revision history for this message
Andre Novellino Gouvêa (andre-ng) wrote :

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) {
[...]

cybermind (iddqd-mail)
Changed in stratagus:
importance: Undecided → Wishlist
status: New → Triaged
assignee: nobody → cybermind (iddqd-mail)
Revision history for this message
Andre Novellino Gouvêa (andre-ng) wrote :

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
};

Revision history for this message
Andre Novellino Gouvêa (andre-ng) wrote :

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
};

Revision history for this message
Andre Novellino Gouvêa (andre-ng) wrote :

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();
}

Revision history for this message
Andre Novellino Gouvêa (andre-ng) wrote :

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;
 }
}

Revision history for this message
timfelgentreff (timfelgentreff) wrote : Moving to GitHub

This project was moved to https://github.com/Wargus/stratagus. All issues were migrated there.

Changed in stratagus:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.