branches/bgfx_shader/src/osd/modules/render/bgfx/chainmanager.cpp
| r255126 | r255127 | |
| 25 | 25 | |
| 26 | 26 | chain_manager::~chain_manager() |
| 27 | 27 | { |
| 28 | | for (std::pair<std::string, bgfx_chain*> chain : m_chains) |
| 28 | for (bgfx_chain* chain : m_chains) |
| 29 | 29 | { |
| 30 | | delete chain.second; |
| 30 | delete chain; |
| 31 | 31 | } |
| 32 | 32 | m_chains.clear(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | | bgfx_chain* chain_manager::chain(std::string name, running_machine& machine, uint32_t window_index) |
| 35 | bgfx_chain* chain_manager::chain(std::string name, running_machine& machine, uint32_t window_index, uint32_t screen_index) |
| 36 | 36 | { |
| 37 | | std::map<std::string, bgfx_chain*>::iterator iter = m_chains.find(name + std::to_string(window_index)); |
| 38 | | if (iter != m_chains.end()) |
| 39 | | { |
| 40 | | return iter->second; |
| 41 | | } |
| 42 | | |
| 43 | | return load_chain(name, machine, window_index); |
| 37 | return load_chain(name, machine, window_index, screen_index); |
| 44 | 38 | } |
| 45 | 39 | |
| 46 | | bgfx_chain* chain_manager::load_chain(std::string name, running_machine& machine, uint32_t window_index) |
| 40 | bgfx_chain* chain_manager::load_chain(std::string name, running_machine& machine, uint32_t window_index, uint32_t screen_index) |
| 47 | 41 | { |
| 48 | 42 | if (name.length() < 5 || (name.compare(name.length() - 5, 5, ".json")!= 0)) |
| 49 | 43 | { |
| r255126 | r255127 | |
| 76 | 70 | return nullptr; |
| 77 | 71 | } |
| 78 | 72 | |
| 79 | | bgfx_chain* chain = chain_reader::read_from_value(document, name + ": ", m_options, machine, window_index, m_textures, m_targets, m_effects, m_width, m_height); |
| 73 | bgfx_chain* chain = chain_reader::read_from_value(document, name + ": ", m_options, machine, window_index, screen_index, m_textures, m_targets, m_effects, m_width, m_height); |
| 80 | 74 | |
| 81 | 75 | if (chain == nullptr) |
| 82 | 76 | { |
| r255126 | r255127 | |
| 84 | 78 | return nullptr; |
| 85 | 79 | } |
| 86 | 80 | |
| 87 | | m_chains[name + std::to_string(window_index)] = chain; |
| 81 | m_chains.push_back(chain); |
| 88 | 82 | |
| 89 | 83 | return chain; |
| 90 | 84 | } |
branches/bgfx_shader/src/osd/modules/render/bgfx/chainmanager.h
| r255126 | r255127 | |
| 14 | 14 | #ifndef __DRAWBGFX_CHAIN_MANAGER__ |
| 15 | 15 | #define __DRAWBGFX_CHAIN_MANAGER__ |
| 16 | 16 | |
| 17 | | #include <map> |
| 17 | #include <vector> |
| 18 | 18 | #include <string> |
| 19 | 19 | |
| 20 | 20 | #include "texturemanager.h" |
| r255126 | r255127 | |
| 39 | 39 | ~chain_manager(); |
| 40 | 40 | |
| 41 | 41 | // Getters |
| 42 | | bgfx_chain* chain(std::string name, running_machine& machine, uint32_t window_index); |
| 42 | bgfx_chain* chain(std::string name, running_machine& machine, uint32_t window_index, uint32_t screen_index); |
| 43 | 43 | |
| 44 | 44 | private: |
| 45 | | bgfx_chain* load_chain(std::string name, running_machine& machine, uint32_t window_index); |
| 45 | bgfx_chain* load_chain(std::string name, running_machine& machine, uint32_t window_index, uint32_t screen_index); |
| 46 | 46 | |
| 47 | 47 | osd_options& m_options; |
| 48 | 48 | texture_manager& m_textures; |
| r255126 | r255127 | |
| 50 | 50 | effect_manager& m_effects; |
| 51 | 51 | uint32_t m_width; |
| 52 | 52 | uint32_t m_height; |
| 53 | | std::map<std::string, bgfx_chain*> m_chains; |
| 53 | std::vector<bgfx_chain*> m_chains; |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | 56 | #endif // __DRAWBGFX_CHAIN_MANAGER__ |
branches/bgfx_shader/src/osd/modules/render/bgfx/chainreader.cpp
| r255126 | r255127 | |
| 24 | 24 | #include "slider.h" |
| 25 | 25 | #include "parameter.h" |
| 26 | 26 | |
| 27 | | bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix, osd_options& options, running_machine& machine, uint32_t window_index, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height) |
| 27 | bgfx_chain* chain_reader::read_from_value(const Value& value, std::string prefix, osd_options& options, running_machine& machine, uint32_t window_index, uint32_t screen_index, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height) |
| 28 | 28 | { |
| 29 | 29 | if (!validate_parameters(value, prefix)) |
| 30 | 30 | { |
| r255126 | r255127 | |
| 41 | 41 | const Value& slider_array = value["sliders"]; |
| 42 | 42 | for (UINT32 i = 0; i < slider_array.Size(); i++) |
| 43 | 43 | { |
| 44 | | std::vector<bgfx_slider*> expanded_sliders = slider_reader::read_from_value(slider_array[i], prefix + "sliders[" + std::to_string(i) + "]: ", machine, window_index); |
| 44 | std::vector<bgfx_slider*> expanded_sliders = slider_reader::read_from_value(slider_array[i], prefix + "sliders[" + std::to_string(i) + "]: ", machine, window_index, screen_index); |
| 45 | 45 | if (expanded_sliders.size() == 0) |
| 46 | 46 | { |
| 47 | 47 | return nullptr; |
branches/bgfx_shader/src/osd/modules/render/bgfx/chainreader.h
| r255126 | r255127 | |
| 21 | 21 | class chain_reader : public state_reader |
| 22 | 22 | { |
| 23 | 23 | public: |
| 24 | | static bgfx_chain* read_from_value(const Value& value, std::string prefix, osd_options& options, running_machine& machine, uint32_t window_index, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height); |
| 24 | static bgfx_chain* read_from_value(const Value& value, std::string prefix, osd_options& options, running_machine& machine, uint32_t window_index, uint32_t screen_index, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t screen_width, uint32_t screen_height); |
| 25 | 25 | |
| 26 | 26 | private: |
| 27 | 27 | static bool validate_parameters(const Value& value, std::string prefix); |
branches/bgfx_shader/src/osd/modules/render/bgfx/sliderreader.cpp
| r255126 | r255127 | |
| 33 | 33 | { "all", uint64_t(bgfx_slider::screen_type::SLIDER_SCREEN_TYPE_ANY) } |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | | std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std::string prefix, running_machine& machine, uint32_t window_index) |
| 36 | std::vector<bgfx_slider*> slider_reader::read_from_value(const Value& value, std::string prefix, running_machine& machine, uint32_t window_index, uint32_t screen_index) |
| 37 | 37 | { |
| 38 | 38 | std::vector<bgfx_slider*> sliders; |
| 39 | 39 | |
| r255126 | r255127 | |
| 83 | 83 | break; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | std::string prefixed_desc = "Window " + std::to_string(window_index) + ", Screen " + std::to_string(screen_index) + ", " + description; |
| 86 | 87 | if (slider_count > 1) |
| 87 | 88 | { |
| 88 | 89 | int min[3]; |
| r255126 | r255127 | |
| 101 | 102 | switch (index) |
| 102 | 103 | { |
| 103 | 104 | case 0: |
| 104 | | desc = "Window " + std::to_string(window_index) + ", " + description + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "X" : "Red"); |
| 105 | desc = prefixed_desc + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "X" : "Red"); |
| 105 | 106 | break; |
| 106 | 107 | case 1: |
| 107 | | desc = "Window " + std::to_string(window_index) + ", " + description + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "Y" : "Green"); |
| 108 | desc = prefixed_desc + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "Y" : "Green"); |
| 108 | 109 | break; |
| 109 | 110 | case 2: |
| 110 | | desc = "Window " + std::to_string(window_index) + ", " + description + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "Invalid" : "Blue"); |
| 111 | desc = prefixed_desc + (type == bgfx_slider::slider_type::SLIDER_VEC2 ? "Invalid" : "Blue"); |
| 111 | 112 | break; |
| 112 | 113 | default: |
| 113 | | desc = "Window " + std::to_string(window_index) + ", " + description + "Invalid"; |
| 114 | desc = prefixed_desc + "Invalid"; |
| 114 | 115 | break; |
| 115 | 116 | } |
| 116 | 117 | sliders.push_back(new bgfx_slider(machine, full_name, min[index], defaults[index], max[index], step, type, screen_type, scale, format, desc, strings)); |
| r255126 | r255127 | |
| 121 | 122 | int min = get_int(value, "min", 0); |
| 122 | 123 | int def = get_int(value, "default", 0); |
| 123 | 124 | int max = get_int(value, "max", 100); |
| 124 | | sliders.push_back(new bgfx_slider(machine, name + "0", min, def, max, step, type, screen_type, scale, format, "Window " + std::to_string(window_index) + ", " + description, strings)); |
| 125 | sliders.push_back(new bgfx_slider(machine, name + "0", min, def, max, step, type, screen_type, scale, format, prefixed_desc, strings)); |
| 125 | 126 | } |
| 126 | 127 | return sliders; |
| 127 | 128 | } |
branches/bgfx_shader/src/osd/modules/render/drawbgfx.cpp
| r255126 | r255127 | |
| 212 | 212 | |
| 213 | 213 | void renderer_bgfx::parse_screen_chains(std::string chain_str) |
| 214 | 214 | { |
| 215 | | std::vector<std::string> chains; |
| 215 | std::vector<std::vector<std::string>> chains; |
| 216 | 216 | uint32_t length = chain_str.length(); |
| 217 | 217 | uint32_t last_start = 0; |
| 218 | uint32_t win = 0; |
| 219 | chains.push_back(std::vector<std::string>()); |
| 218 | 220 | for (uint32_t i = 0; i < length + 1; i++) |
| 219 | 221 | { |
| 220 | | if (i == length || chain_str[i] == ',') |
| 222 | if (i == length || chain_str[i] == ',' || chain_str[i] == ':') |
| 221 | 223 | { |
| 222 | | chains.push_back(chain_str.substr(last_start, i - last_start)); |
| 224 | chains[win].push_back(chain_str.substr(last_start, i - last_start)); |
| 223 | 225 | last_start = i + 1; |
| 226 | if (chain_str[i] == ':') |
| 227 | { |
| 228 | win++; |
| 229 | chains.push_back(std::vector<std::string>()); |
| 230 | } |
| 224 | 231 | } |
| 225 | 232 | } |
| 226 | 233 | |
| 227 | | for (uint32_t index = 0; index < chains.size(); index++) |
| 234 | for (win = 0; win < chains.size(); win++) |
| 228 | 235 | { |
| 229 | | bgfx_chain* chain = m_chains->chain(chains[index], window().machine(), index); |
| 230 | | if (chain == nullptr) |
| 236 | m_screen_chains.push_back(std::vector<bgfx_chain*>()); |
| 237 | if (win != window().m_index) |
| 231 | 238 | { |
| 232 | | chains.clear(); |
| 233 | | return; |
| 239 | continue; |
| 234 | 240 | } |
| 235 | | m_screen_chains.push_back(chain); |
| 241 | for (uint32_t screen = 0; screen < chains[win].size(); screen++) |
| 242 | { |
| 243 | bgfx_chain* chain = m_chains->chain(chains[win][screen], window().machine(), win, screen); |
| 244 | if (chain == nullptr) { |
| 245 | chains.clear(); |
| 246 | return; |
| 247 | } |
| 248 | m_screen_chains[win].push_back(chain); |
| 249 | } |
| 236 | 250 | } |
| 237 | 251 | } |
| 238 | 252 | |
| r255126 | r255127 | |
| 759 | 773 | |
| 760 | 774 | int renderer_bgfx::handle_screen_chains() |
| 761 | 775 | { |
| 762 | | if (m_screen_chains.size() == 0) |
| 776 | if (m_screen_chains.size() <= window().m_index || m_screen_chains[window().m_index].size() == 0) |
| 763 | 777 | { |
| 764 | 778 | return 0; |
| 765 | 779 | } |
| r255126 | r255127 | |
| 802 | 816 | |
| 803 | 817 | bgfx_chain* renderer_bgfx::screen_chain(int32_t screen) |
| 804 | 818 | { |
| 805 | | if (screen >= m_screen_chains.size()) |
| 819 | if (screen >= m_screen_chains[window().m_index].size()) |
| 806 | 820 | { |
| 807 | | return m_screen_chains[m_screen_chains.size() - 1]; |
| 821 | return m_screen_chains[window().m_index][m_screen_chains.size() - 1]; |
| 808 | 822 | } |
| 809 | 823 | else |
| 810 | 824 | { |
| 811 | | return m_screen_chains[screen]; |
| 825 | return m_screen_chains[window().m_index][screen]; |
| 812 | 826 | } |
| 813 | 827 | } |
| 814 | 828 | |
| r255126 | r255127 | |
| 975 | 989 | return BUFFER_PRE_FLUSH; |
| 976 | 990 | } |
| 977 | 991 | |
| 978 | | if (PRIMFLAG_GET_SCREENTEX((*prim)->flags) && m_screen_chains.size() > 0) |
| 992 | if (PRIMFLAG_GET_SCREENTEX((*prim)->flags) && m_screen_chains.size() > window().m_index && m_screen_chains[window().m_index].size() > 0) |
| 979 | 993 | { |
| 980 | 994 | render_post_screen_quad(view, *prim, buffer, screen); |
| 981 | 995 | return BUFFER_SCREEN; |
| r255126 | r255127 | |
| 1195 | 1209 | |
| 1196 | 1210 | slider_state* renderer_bgfx::get_slider_list() |
| 1197 | 1211 | { |
| 1198 | | if (m_screen_chains.size() == 0) |
| 1212 | if (m_screen_chains.size() <= window().m_index || m_screen_chains[window().m_index].size() == 0) |
| 1199 | 1213 | { |
| 1200 | 1214 | return nullptr; |
| 1201 | 1215 | } |
| 1202 | 1216 | |
| 1203 | 1217 | slider_state *listhead = nullptr; |
| 1204 | 1218 | slider_state **tailptr = &listhead; |
| 1205 | | for (bgfx_chain* chain : m_screen_chains) |
| 1219 | for (std::vector<bgfx_chain*> screen : m_screen_chains) |
| 1206 | 1220 | { |
| 1207 | | std::vector<bgfx_slider*> sliders = chain->sliders(); |
| 1208 | | for (bgfx_slider* slider : sliders) |
| 1221 | for (bgfx_chain* chain : screen) |
| 1209 | 1222 | { |
| 1210 | | if (*tailptr == nullptr) |
| 1223 | std::vector<bgfx_slider*> sliders = chain->sliders(); |
| 1224 | for (bgfx_slider* slider : sliders) |
| 1211 | 1225 | { |
| 1212 | | *tailptr = slider->core_slider(); |
| 1226 | if (*tailptr == nullptr) |
| 1227 | { |
| 1228 | *tailptr = slider->core_slider(); |
| 1229 | } |
| 1230 | else |
| 1231 | { |
| 1232 | (*tailptr)->next = slider->core_slider(); |
| 1233 | tailptr = &(*tailptr)->next; |
| 1234 | } |
| 1213 | 1235 | } |
| 1214 | | else |
| 1215 | | { |
| 1216 | | (*tailptr)->next = slider->core_slider(); |
| 1217 | | tailptr = &(*tailptr)->next; |
| 1218 | | } |
| 1219 | 1236 | } |
| 1220 | 1237 | } |
| 1221 | 1238 | if (*tailptr != nullptr) |
branches/bgfx_shader/src/osd/windows/window.cpp
| r255126 | r255127 | |
| 272 | 272 | |
| 273 | 273 | void windows_osd_interface::build_slider_list() |
| 274 | 274 | { |
| 275 | | // FIXME: take all sliders from all windows without concatenate them by slider_state->next |
| 276 | | |
| 275 | m_sliders = nullptr; |
| 276 | slider_state* full_list = nullptr; |
| 277 | slider_state* curr = nullptr; |
| 277 | 278 | for (win_window_info *window = win_window_list; window != nullptr; window = window->m_next) |
| 278 | 279 | { |
| 279 | 280 | // take the sliders of the first window |
| 280 | | m_sliders = window->m_renderer->get_slider_list(); |
| 281 | | return; |
| 281 | slider_state* window_sliders = window->m_renderer->get_slider_list(); |
| 282 | if (window_sliders == nullptr) |
| 283 | { |
| 284 | continue; |
| 285 | } |
| 286 | |
| 287 | if (full_list == nullptr) |
| 288 | { |
| 289 | full_list = curr = window_sliders; |
| 290 | } |
| 291 | else |
| 292 | { |
| 293 | curr->next = window_sliders; |
| 294 | } |
| 295 | |
| 296 | while (curr->next != nullptr) { |
| 297 | curr = curr->next; |
| 298 | } |
| 282 | 299 | } |
| 300 | |
| 301 | m_sliders = full_list; |
| 283 | 302 | } |
| 284 | 303 | |
| 285 | 304 | //============================================================ |