Advertisement
Guest User

Untitled

a guest
Feb 14th, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.59 KB | None | 0 0
  1. /**** Sprite Aligner ****/
  2.  
  3. /** Window used for aligning sprites. */
  4. struct SpriteAlignerWindow : Window {
  5.     SpriteID current_sprite; ///< The currently shown sprite
  6.     Scrollbar *vscroll;
  7.     SmallMap<SpriteID, int> sprite_start_pos_map; ///< Mapping of offsets of all sprites viewed since opening the window
  8.  
  9.     SpriteAlignerWindow(WindowDesc *desc, WindowNumber wno) : Window(desc)
  10.     {
  11.         this->CreateNestedTree();
  12.         this->vscroll = this->GetScrollbar(WID_SA_SCROLLBAR);
  13.         this->FinishInitNested(wno);
  14.  
  15.         /* Oh yes, we assume there is at least one normal sprite! */
  16.         while (GetSpriteType(this->current_sprite) != ST_NORMAL) SetCurrentSprite(this->current_sprite + 1);
  17.     }
  18.  
  19.     void SetCurrentSprite(const SpriteID new_sprite)
  20.     {
  21.         this->current_sprite = new_sprite;
  22.  
  23.         if (this->sprite_start_pos_map.Contains(new_sprite)) return;
  24.         /* Remember the original offset of the new sprite */
  25.         this->sprite_start_pos_map.Insert(new_sprite, GetSprite(new_sprite, ST_NORMAL)->x_offs);
  26.     }
  27.  
  28.     virtual void SetStringParameters(int widget) const
  29.     {
  30.         const Sprite *spr = GetSprite(this->current_sprite, ST_NORMAL);
  31.         switch (widget) {
  32.             case WID_SA_CAPTION:
  33.                 SetDParam(0, this->current_sprite);
  34.                 SetDParamStr(1, FioGetFilename(GetOriginFileSlot(this->current_sprite)));
  35.                 break;
  36.  
  37.             case WID_SA_OFFSETS: {
  38.                 SetDParam(0, spr->x_offs);
  39.                 SetDParam(1, spr->y_offs);
  40.                 break;
  41.             }
  42.             case WID_SA_OFFSETS_REL: {
  43.                 SetDParam(0, this->sprite_start_pos_map[this->current_sprite] - spr->x_offs);
  44.                 SetDParam(1, this->sprite_start_pos_map[this->current_sprite] - spr->y_offs);
  45.                 break;
  46.             }
  47.  
  48.             default:
  49.                 break;
  50.         }
  51.     }
  52.  
  53.  
  54.  
  55.  
  56. [SRC] Compiling newgrf_debug_gui.cpp
  57. /home/tim/ttdp/openttd/trunk/src/newgrf_debug_gui.cpp: In member function ‘virtual void SpriteAlignerWindow::SetStringParameters(int) const:
  58. /home/tim/ttdp/openttd/trunk/src/newgrf_debug_gui.cpp:846:65: error: passing ‘const SmallMap<unsigned int, int>’ as ‘this’ argument of ‘U& SmallMap<T, U, S>::operator[](const T&) [with T = unsigned int; U = int; unsigned int S = 16u]’ discards qualifiers [-fpermissive]
  59.      SetDParam(0, this->sprite_start_pos_map[this->current_sprite] - spr->x_offs);
  60.                                                                  ^
  61. /home/tim/ttdp/openttd/trunk/src/newgrf_debug_gui.cpp:847:65: error: passing ‘const SmallMap<unsigned int, int>’ as ‘this’ argument of ‘U& SmallMap<T, U, S>::operator[](const T&) [with T = unsigned int; U = int; unsigned int S = 16u]’ discards qualifiers [-fpermissive]
  62.      SetDParam(1, this->sprite_start_pos_map[this->current_sprite] - spr->y_offs);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement