src/town_gui.cpp
branchnoai
changeset 11126 72d4c9314c72
parent 11044 097ea3e7ec56
equal deleted inserted replaced
11111:1b984dab8cec 11126:72d4c9314c72
   111 
   111 
   112 	if (nump != NULL) *nump = num;
   112 	if (nump != NULL) *nump = num;
   113 	return buttons;
   113 	return buttons;
   114 }
   114 }
   115 
   115 
   116 /**
       
   117  * Get the position of the Nth set bit.
       
   118  *
       
   119  * If there is no Nth bit set return -1
       
   120  *
       
   121  * @param bits The value to search in
       
   122  * @param n The Nth set bit from which we want to know the position
       
   123  * @return The position of the Nth set bit
       
   124  */
       
   125 static int GetNthSetBit(uint32 bits, int n)
       
   126 {
       
   127 	if (n >= 0) {
       
   128 		uint i;
       
   129 		FOR_EACH_SET_BIT(i, bits) {
       
   130 			n--;
       
   131 			if (n < 0) return i;
       
   132 		}
       
   133 	}
       
   134 	return -1;
       
   135 }
       
   136 
       
   137 struct TownAuthorityWindow : Window {
   116 struct TownAuthorityWindow : Window {
   138 private:
   117 private:
   139 	Town *town;
   118 	Town *town;
   140 	int sel_index;
   119 	int sel_index;
   141 
   120 
   146 		TWA_COMMAND_LIST,
   125 		TWA_COMMAND_LIST,
   147 		TWA_SCROLLBAR,
   126 		TWA_SCROLLBAR,
   148 		TWA_ACTION_INFO,
   127 		TWA_ACTION_INFO,
   149 		TWA_EXECUTE,
   128 		TWA_EXECUTE,
   150 	};
   129 	};
       
   130 
       
   131 	/**
       
   132 	 * Get the position of the Nth set bit.
       
   133 	 *
       
   134 	 * If there is no Nth bit set return -1
       
   135 	 *
       
   136 	 * @param bits The value to search in
       
   137 	 * @param n The Nth set bit from which we want to know the position
       
   138 	 * @return The position of the Nth set bit
       
   139 	 */
       
   140 	static int GetNthSetBit(uint32 bits, int n)
       
   141 	{
       
   142 		if (n >= 0) {
       
   143 			uint i;
       
   144 			FOR_EACH_SET_BIT(i, bits) {
       
   145 				n--;
       
   146 				if (n < 0) return i;
       
   147 			}
       
   148 		}
       
   149 		return -1;
       
   150 	}
   151 
   151 
   152 public:
   152 public:
   153 	TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) :
   153 	TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) :
   154 			Window(desc, window_number), sel_index(-1)
   154 			Window(desc, window_number), sel_index(-1)
   155 	{
   155 	{