| 126 | } |
| 127 | |
| 128 | void Window_VarList::UpdateList(int first_value){ |
| 129 | static std::stringstream ss; |
| 130 | first_var = first_value; |
| 131 | int map_idx = 0; |
| 132 | if (mode == eMap) { |
| 133 | auto iter = std::lower_bound(lcf::Data::treemap.maps.begin(), lcf::Data::treemap.maps.end(), first_value, |
| 134 | [](const lcf::rpg::MapInfo& l, int r) { return l.ID < r; }); |
| 135 | map_idx = iter - lcf::Data::treemap.maps.begin(); |
| 136 | } |
| 137 | |
| 138 | for (int i = 0; i < LINE_COUNT; i++) { |
| 139 | this->SetItemText(i, ""); |
| 140 | } |
| 141 | |
| 142 | const int item_count = GetItemCount(); |
| 143 | for (int i = 0; i < item_count; i++){ |
| 144 | if (!DataIsValid(first_var+i)) { |
| 145 | continue; |
| 146 | } |
| 147 | ss.str(""); |
| 148 | ss << std::setfill('0') << std::setw(GetDigitCount()) << (first_value + i) << ": "; |
| 149 | switch (mode) { |
| 150 | case eSwitch: |
| 151 | ss << Main_Data::game_switches->GetName(first_value + i); |
| 152 | break; |
| 153 | case eVariable: |
| 154 | ss << Main_Data::game_variables->GetName(first_value + i); |
| 155 | break; |
| 156 | case eItem: |
| 157 | ss << lcf::ReaderUtil::GetElement(lcf::Data::items, first_value+i)->name; |
| 158 | break; |
| 159 | case eTroop: |
| 160 | ss << lcf::ReaderUtil::GetElement(lcf::Data::troops, first_value+i)->name; |
| 161 | break; |
| 162 | case eMap: |
| 163 | if (map_idx < static_cast<int>(lcf::Data::treemap.maps.size())) { |
| 164 | auto& map = lcf::Data::treemap.maps[map_idx]; |
| 165 | if (map.ID == first_value + i) { |
| 166 | ss << map.name; |
| 167 | ++map_idx; |
| 168 | } |
| 169 | } |
| 170 | break; |
| 171 | case eHeal: |
| 172 | if (first_value + i == 1) { |
| 173 | ss << "Party"; |
| 174 | } else { |
| 175 | auto* actor = Main_Data::game_party->GetActors()[first_value + i-2]; |
| 176 | ss << actor->GetName() << " " << actor->GetHp() << " / " << actor->GetMaxHp(); |
| 177 | } |
| 178 | break; |
| 179 | case eLevel: |
| 180 | if (first_value + i >= 1) { |
| 181 | auto* actor = Main_Data::game_party->GetActors()[first_value + i-1]; |
| 182 | ss << actor->GetName(); |
| 183 | } |
| 184 | break; |
| 185 | case eCommonEvent: |