def bltgui_menu(terminal, x_offset, y_offset, header, options, desc, frame_list, hide_options): items = [] item_dict = {} if header is not None: i_width = len(header)+2 header_h = 1 if not hide_options: items = options i_width = max(30, len(max(items,key=len)) + 8) header_h = len(textwrap.wrap(header, i_width))+2 list_frame = Frame(x_offset,y_offset,i_width,max(len(items)+header_h+2,8), "", text=header, frame=True, draggable=True, color_skin = 'GRAY', font = '[font=big]', title_font='[font=big]') list_frame.add_control(bltGui.bltResizeFrameButton(list_frame)) list_box = bltGui.bltListbox(list_frame, 1, header_h+1, items, False, True) if desc is not None: item_dict = make_item_dict(options, desc) content_frame = bltGui.bltShowListFrame(i_width + x_offset, y_offset,25,20, "", frame=True, draggable=True, color_skin = 'GRAY', font = '[font=text]', title_font='[font=big]') content_frame.set_dict(item_dict) content_frame.add_control(bltGui.bltResizeFrameButton(content_frame)) list_box.register('changed', content_frame) else: content_frame = None else: content_frame = None list_box = None list_frame = Frame(x_offset,y_offset,i_width,len(items)+header_h+2, "", text=header, frame=True, draggable=True, color_skin = 'GRAY', font = '[font=text]', title_font='[font=big]') if list_box is not None: list_frame.add_control(list_box) frame_list.append(list_frame) if content_frame is not None: frame_list.append(content_frame)
def bltgui_page(terminal, w, h, menu_dict, frame_list): items = menu_dict.get('options') desc = menu_dict.get('desc') list_box = None content_frame = None list_frame = Frame(0,0,w,h,'', text='', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') if len(items) > 0: list_box = bltGui.bltListbox(list_frame, 5, 5, items, False, True) if desc is not None: item_dict = make_item_dict(items, desc) content_frame = bltGui.bltShowListFrame(41, 15,120,70, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=text]', title_font='[font=big]') content_frame.set_dict(item_dict) slider = bltGui.bltSlider(content_frame,55,0,10,0,min_val=1,max_val=4,visible=False,skin='SOLID',label='Page') content_frame.add_control(slider) list_box.register('changed', content_frame) else: content_frame = None if list_box is not None: list_frame.add_control(list_box) frame_list.append(list_frame) if content_frame is not None: frame_list.append(content_frame)
def bltgui_age_page(terminal, w, h, menu_dict, frame_list): items = menu_dict.get('options') desc = menu_dict.get('desc') header = menu_dict.get('header') list_frame = Frame(0,5,w,15,'', text='', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') if len(items) > 0: list_box = bltGui.bltListbox(list_frame, 87, 10, items, False, True) list_frame.add_control(list_box) text_box = NumBox(list_frame,88,5,desc.get('age'),min_val=16,max_val=60) desc_frame = Frame(30, 20,120,70,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=text]', title_font='[font=big]') desc_frame.name = 'desc frame' desc_frame.text = 'Mods based on your age: \n' + desc.get('age mods') list_frame.add_control(text_box) frame_list.append(list_frame) frame_list.append(desc_frame)
def bltgui_name_page(terminal, w, h, menu_dict, frame_list): items = menu_dict.get('options') desc = menu_dict.get('desc') header = menu_dict.get('header') list_frame = Frame(0,5,w,15,'', text='', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') if len(items) > 0: list_box = bltGui.bltListbox(list_frame, 87, 10, items, False, True) list_frame.add_control(list_box) text_box = bltTextBox(list_frame,88,5,desc.get('name'),length=30) list_frame.add_control(text_box) frame_list.append(list_frame)
def bltgui_attrpage(terminal, w, h, menu_dict, frame_list): desc = menu_dict.get('desc') rolls = desc.get('rolls') items = menu_dict.get('options') list_frame = Frame(0,0,20,h,'', text='', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') list_box = bltGui.bltListbox(list_frame, 5, 5, items, False, True) list_frame.add_control(list_box) roll_frame = bltGui.bltShowListFrame(21,5,10,h-5, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=text]', title_font='[font=big]') roll_frame.name = 'roll_frame' scale_frame = bltGui.bltShowListFrame(31,5,120,h-5, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=text]', title_font='[font=big]') scale_text1 = 'Generic Attribute Scale\n***********************************************************************\nScore Description\n======= ============================================================\n' scale_text2 = '0-10 Almost completely disabled\n11-20 Very disabled\n21-30 Moderately disabled\n31-60 Slightly disabled\n61-80 Well below average\n' scale_text3 = '81-90 Below average\n91-100 Average\n101-110 Above average\n111-140 Well above average\n141-160 Exceptional\n161-180 Highly Exceptional\n181-200 Genetically gifted\n200+ Legendary' scale_frame.text = scale_text1 + scale_text2 + scale_text3 frame_list.append(list_frame) frame_list.append(scale_frame) frame_list.append(roll_frame)
def bltgui_rollpage(terminal, w, h, menu_dict, frame_list): desc = menu_dict.get('desc') items = menu_dict.get('options') list_frame = Frame(0,0,w,h,'', text='', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') content_frame = bltGui.bltShowListFrame(41,15,120,70, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=text]', title_font='[font=big]') list_box = bltGui.bltListbox(list_frame, 5, 5, items, False, True) list_frame.add_control(list_box) if desc.get('roll') > 0: prof_string = '' prof_list = list(desc.get('prof')) for p in prof_list: if p == prof_list[-1]: prof_string = prof_string + p else: prof_string = prof_string + p + ', ' content_frame.text = 'Roll: ' + str(desc.get('roll')) + '\nSocial Standing: ' + desc.get('standing') + '\nAllowed Professions: ' + prof_string frame_list.append(list_frame) frame_list.append(content_frame)
def bltgui_store_page(terminal, w, h, menu_dict, frame_list): items = menu_dict.get('options') list_box = None list_frame = Frame(0,0,20,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') price_frame = Frame(155,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') weight_frame = Frame(145,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') length_frame = Frame(135,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') hit_frame = Frame(125,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') parry_frame = Frame(115,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') damage_frame = Frame(105,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') hands_frame = Frame(95,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') er_frame = Frame(85,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') ap_frame = Frame(75,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') pap_frame = Frame(65,14,10,26,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') desc_frame = Frame(5,42,150,15,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') purch_frame = Frame(5,57,150,5,'', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') if len(items) > 0: list_box = bltGui.bltListbox(list_frame, 5, 16, items, False, True) if list_box is not None: list_frame.add_control(list_box) frame_list.extend([purch_frame,desc_frame,price_frame,weight_frame,length_frame,hit_frame,parry_frame,damage_frame,hands_frame,er_frame,ap_frame,pap_frame,list_frame])
def bltgui_assn_attr(terminal, w, h, menu_dict, frame_list): desc = menu_dict.get('desc') roll = desc.get('roll') attributes = desc.get('attributes') items = menu_dict.get('options') attr_mods = desc.get('attr_mods') desc1 = {'Revert':'Revert all attribute choices and start over'} sex_mods = {} eth_mods = {} desc2 = {} desc3 = {} for key,value in attr_mods.items(): if attr_mods.get(key).get('sex'): sex_mods[key] = attr_mods.get(key).get('sex') if attr_mods.get(key).get('ethnicity'): eth_mods[key] = attr_mods.get(key).get('ethnicity') #Build dict for desc1 frame for o in items: if not desc1.get(o): sm = 0 em = 0 if sex_mods.get(o): sm = sex_mods.get(o) if eth_mods.get(o): em = eth_mods.get(o) desc1[o] = 'Base Rating: '+str(roll)+'\tSex Mod: '+str(sm)+'\tEthnicity Mod: '+str(em)+'\tFinal Rating: '+str(roll+sm+em) #Build dict for desc3 frame for key,value in attributes.items(): if key == o: desc3[key] = rating_description(key,roll+sm+em) #Build dict for desc2_frame for key,value in attributes.items(): desc2[key] = attr_descriptions(key) list_frame = Frame(0,10,30,h-20,'', text='', frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=head]') list_frame.name = 'list_frame' list_box = bltGui.bltListbox(list_frame, 5, 0, items, False, True) list_frame.add_control(list_box) desc1_frame = bltGui.bltShowListFrame(31,11,w-70,10, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=big]') desc1_frame.name = 'desc1_frame' desc2_frame = bltGui.bltShowListFrame(31,21,w-70,10, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=big]') desc2_frame.name = 'desc2_frame' desc3_frame = bltGui.bltShowListFrame(31,41,w-70,30, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=big]') desc3_frame.name = 'desc3_frame' profs_frame = bltGui.bltShowListFrame(31,71,w-70,10, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=big]') profs_frame.name = 'profs_frame' attrs_frame = bltGui.bltShowListFrame(141,10,40,h-10, "", frame=False, draggable=False, color_skin = 'GRAY', font = '[font=big]', title_font='[font=big]') attrs_frame.name = 'attrs_frame' list_box.register('changed', desc1_frame) list_box.register('changed', desc2_frame) list_box.register('changed', desc3_frame) if desc is not None: item_dict = make_item_dict(items, desc1) item_dict2 = make_item_dict(items, desc2) item_dict3 = make_item_dict(items, desc3) desc1_frame.set_dict(item_dict) desc2_frame.set_dict(item_dict2) desc3_frame.set_dict(item_dict3) frame_list.append(list_frame) frame_list.append(desc1_frame) frame_list.append(desc2_frame) frame_list.append(desc3_frame) frame_list.append(attrs_frame) frame_list.append(profs_frame)
def initilize(): dkrgry = Color('darkest grey').trans(200) control_frame = Frame(55, 30, 20, 15, "Control Test", visible=True, draggable=True, skin='SOLID') # control_frame.add_control(bltButton(control_frame, # control_frame.width/2, 5, "X", # length=10, # function=bltButton.close)) control_frame.add_control(CloseFrameButton(control_frame)) control_frame.add_control(TextBox(control_frame, 2, 2, "Text Box", length=9)) control_frame.add_control(CheckBoxButton(control_frame, 2, 4, label="CheckboxA")) control_frame.add_control(CheckBoxButton(control_frame, 2, 5, label="CheckboxB")) control_frame.add_control(CheckBoxButton(control_frame, 2, 6, label="CheckboxC")) radio = Radio(control_frame, 2, 9, label="Radio Button") control_frame.add_control(radio) radio_listener = Frame(30, 45, 18, 4, title="Radio Selection") print("Radio Events: {0}".format(radio.subscribers)) radio.register('changed', radio_listener) sample_text_frame = Frame(5, 30, 10, 10, visible=True) sample_text_frame.text = sample_text sample_text_frame.add_control(ResizeFrameButton(sample_text_frame)) sample_text_frame.add_control(Button(sample_text_frame, 8, 14, "Show Controls", function=control_frame.show)) color_grad = Color.color_map(['red', 'blue'], [0, 5]) # color_grad = [] x = 40 y = 3 for i, c in enumerate(color_grad): f = Frame(x, y, 20, 10, title="Test Box {0}".format(i), draggable=True, visible=True, skin='DOUBLE') f.color_skin['BKCOLOR'] = c f.color_skin['COLOR'] = 'darkest grey' frame_list.append(f) frame_list[-1].add_control(ResizeFrameButton(frame_list[-1])) x += 1 y += 1 key = Input.update() mouse = Input.mouse slider_r_value = 254 slider_g_value = 0 slider_b_value = 0 slider_a_value = 255 def update_r_val(value): global slider_r_value slider_r_value = value def update_g_val(value): global slider_g_value slider_g_value = value def update_b_val(value): global slider_b_value slider_b_value = value def update_a_val(value): global slider_a_value slider_a_value = value color_picker = Frame(30, 30, 18, 11, "Color Picker", visible=True, draggable=True) r_slider = Slider(color_picker, 2, 2, 14, slider_r_value, min_val=0, max_val=255, update_func=update_r_val, label='R', style='fill') g_slider = Slider(color_picker, 2, 4, 14, slider_g_value, min_val=0, max_val=255, update_func=update_g_val, label='G', style='fill') b_slider = Slider(color_picker, 2, 6, 14, slider_b_value, min_val=0, max_val=255, update_func=update_b_val, label='B', style='fill') a_slider = Slider(color_picker, 2, 8, 14, slider_a_value, min_val=0, max_val=255, update_func=update_a_val, label='A', style='fill') color_picker.add_control([r_slider, g_slider, b_slider, a_slider]) color_picker.add_control(ResizeFrameButton(color_picker)) frame_list.append(color_picker) frame_list.append(control_frame) frame_list.append(sample_text_frame) frame_list.append(radio_listener) tb = TextBox(None, 25, 1, text="TEST")
def draw_demo(): terminal.layer(1) background = Frame(1, 1, 78, 23, bkcolor='20,20,20', frame=False, visible=True, layer=0) x, y = 4, 2 terminal.color('230,230,230') terminal.puts(x - 2, y, "[c=amber]1. [/c]Set alpha.") color_a = Color('flame') terminal.puts(x, y + 1, "[c={0}]{0}[/c].trans(128) = [c={1}]{0}" .format(color_a, color_a.trans(128))) y += 3 terminal.puts(x - 2, y, "[c=amber]2. [/c]Multiply color by float.") color_a = Color('green') terminal.puts(x, y + 1, "[c={0}]{0}[/c] * 0.25 = [c={1}]{0}" .format(color_a, color_a * 0.25)) y += 3 terminal.puts(x - 2, y, "[c=amber]3. [/c]Multiply two colors.") color_a = Color('sky') color_b = Color('purple') terminal.puts(x, y + 1, "[c={0}]{0}[/c] * [c={1}]{1}[/c] = [c={2}]Result" .format(color_a, color_b, color_a * color_b)) y += 3 terminal.puts(x - 2, y, "[c=amber]4. [/c]Subtract two colors.") color_a = Color('sky') color_b = Color('purple') terminal.puts(x, y + 1, "[c={0}]{0}[/c] - [c={1}]{1}[/c] = [c={2}]Result" .format(color_a,color_b, color_a - color_b)) y += 3 terminal.puts(x - 2, y, "[c=amber]5. [/c]Add two colors.") color_a = Color('sky') color_b = Color('purple') terminal.puts(x, y + 1, "[c={0}]{0}[/c] + [c={1}]{1}[/c] = [c={2}]Result" .format(color_a, color_b, color_a + color_b)) y += 3 terminal.puts(x - 2, y, "[c=amber]6. [/c]Blend two colors w/ bias.") color_a = Color('red') color_b = Color('blue') terminal.puts(x, y + 1, "[c={0}]{0}[/c].blend([c={1}]{1}[/c], 0.25) = [c={2}]Result" .format(color_a, color_b, color_a.blend(color_b, bias=0.25))) terminal.puts(x, y + 2, "[c={0}]{0}[/c].blend([c={1}]{1}[/c], 0.75) = [c={2}]Result" .format(color_a, color_b, color_a.blend(color_b, bias=0.75))) y += 4 terminal.puts(x - 2, y, ("[c=amber]7. [/c]Color map.[c=grey] " "bltColor.color_map(color_list, key_list)[/c]")) color_list = ['red', 'orange', 'yellow', 'green', 'purple'] key_list = [0, 25, 30, 50, 60] cmap = Color.color_map(color_list, key_list) for c in cmap: terminal.puts(x, y + 1, "[c={0}][U+2588]".format(c)) x += 1 background.draw()
("[c=amber]7. [/c]Color map.[c=grey] " "bltColor.color_map(color_list, key_list)[/c]")) color_list = ['red', 'orange', 'yellow', 'green', 'purple'] key_list = [0, 25, 30, 50, 60] cmap = Color.color_map(color_list, key_list) for c in cmap: terminal.puts(x, y + 1, "[c={0}][U+2588]".format(c)) x += 1 background.draw() initilize() # draw_demo() list_frame = Frame(3, 5, 9, 6, "", frame=True, draggable=False) content_frame = ShowListFrame(12, 5, 25, 20, "", frame=True, draggable=False) list_box = ListBox(list_frame, 1, 1, ['Item 1', 'Item 2', 'Item 3', 'Item 4']) list_frame.add_control(list_box) content_frame.add_control(ResizeFrameButton(content_frame)) list_box.register('changed', content_frame) modal = ModalFrame(45, 5, 7, 7, "Modal", frame=True, draggable=True)