<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from functools import partial <EOL> from panda3d . core import Vec3 <EOL> from rplibs . yaml import load_yaml_file <EOL> from rpcore . native import NATIVE_CXX_LOADED <EOL> from rpcore . gui . draggable_window import DraggableWindow <EOL> from rpcore . gui . labeled_checkbox import LabeledCheckbox <EOL> from rpcore . gui . checkbox_collection import CheckboxCollection <EOL> class RenderModeSelector ( DraggableWindow ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , pipeline , parent ) : <EOL> DraggableWindow . __init__ ( self , width = <NUM_LIT> , height = <NUM_LIT> , parent = parent , <EOL> title = "<STR_LIT>" ) <EOL> self . _pipeline = pipeline <EOL> self . _selected_mode = "<STR_LIT>" <EOL> self . _create_components ( ) <EOL> self . hide ( ) <EOL> def _create_components ( self ) : <EOL> """<STR_LIT>""" <EOL> DraggableWindow . _create_components ( self ) <EOL> self . _content_node = self . _node . attach_new_node ( "<STR_LIT:content>" ) <EOL> self . _populate_content ( ) <EOL> def _populate_content ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _content_node . node ( ) . remove_all_children ( ) <EOL> config = load_yaml_file ( "<STR_LIT>" ) <EOL> debugger_content = self . _content_node . attach_new_node ( "<STR_LIT>" ) <EOL> debugger_content . set_z ( - <NUM_LIT:20> ) <EOL> debugger_content . set_x ( <NUM_LIT:20> ) <EOL> render_modes = [ ( "<STR_LIT>" , "<STR_LIT>" , False , "<STR_LIT>" , False ) ] <EOL> for mode in config [ "<STR_LIT>" ] : <EOL> data = [ mode [ "<STR_LIT:name>" ] , mode [ "<STR_LIT:key>" ] ] <EOL> data . append ( mode . get ( "<STR_LIT>" , False ) ) <EOL> data . append ( mode . get ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> data . append ( mode . get ( "<STR_LIT>" , False ) ) <EOL> render_modes . append ( data ) <EOL> collection = CheckboxCollection ( ) <EOL> for idx , ( mode , mode_id , requires_cxx , requires_plugin , special ) in enumerate ( render_modes ) : <EOL> offs_y = ( idx // <NUM_LIT:3> ) * <NUM_LIT> + <NUM_LIT> <EOL> offs_x = idx % <NUM_LIT:3> * <NUM_LIT> <EOL> enabled = True <EOL> if requires_cxx and not NATIVE_CXX_LOADED : <EOL> enabled = False <EOL> if requires_plugin : <EOL> if not self . _pipeline . plugin_mgr . is_plugin_enabled ( requires_plugin ) : <EOL> enabled = False <EOL> box = LabeledCheckbox ( <EOL> parent = debugger_content , x = offs_x , y = offs_y , text = mode . upper ( ) , <EOL> text_color = Vec3 ( <NUM_LIT> ) , radio = True , chb_checked = ( mode_id == self . _selected_mode ) , <EOL> chb_callback = partial ( self . _set_render_mode , mode_id , special ) , <EOL> text_size = <NUM_LIT> , expand_width = <NUM_LIT> , enabled = enabled ) <EOL> collection . add ( box . checkbox ) <EOL> def _set_render_mode ( self , mode_id , special , value ) : <EOL> """<STR_LIT>""" <EOL> if not value : <EOL> return <EOL> to_remove = [ ] <EOL> for define in self . _pipeline . stage_mgr . defines : <EOL> if define . startswith ( "<STR_LIT>" ) : <EOL> to_remove . append ( define ) <EOL> for define in to_remove : <EOL> del self . _pipeline . stage_mgr . defines [ define ] <EOL> if mode_id == "<STR_LIT>" : <EOL> self . _pipeline . stage_mgr . defines [ "<STR_LIT>" ] = <NUM_LIT:0> <EOL> else : <EOL> self . _pipeline . stage_mgr . defines [ "<STR_LIT>" ] = <NUM_LIT:0> if special else <NUM_LIT:1> <EOL> self . _pipeline . stage_mgr . defines [ "<STR_LIT>" + mode_id ] = <NUM_LIT:1> <EOL> self . _selected_mode = mode_id <EOL> self . _pipeline . reload_shaders ( ) <EOL> def toggle ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . _visible : <EOL> self . hide ( ) <EOL> else : <EOL> self . _populate_content ( ) <EOL> self . show ( ) </s>
