Exemple #1
0
    GLWindow::GLWindow():PythonObject<GLWindow>(this),
			 glfwWindowPointer_(glfwCreateWindow(600,600,"scigma", NULL,Application::get_instance()->get_master_window())),
			 glContext_(glfwWindowPointer_),
			 viewingArea_(glfwWindowPointer_,&glContext_),
			 viewingVolume_(&glContext_),
			 cursorX_(cursorPosition_),
			 cursorY_(cursorPosition_+1),
			 cursorLastX_(cursorPosition_+2),
			 cursorLastY_(cursorPosition_+3)
    {
      Application::get_instance()->glfw_window_set_callbacks(glfwWindowPointer_);
      glfwSetWindowUserPointer(glfwWindowPointer_,static_cast<void*>(this));
      TwSetCurrentWindow(size_t(&glContext_));
      TwDefine(" GLOBAL iconpos=topright ");
      TwDefine(" GLOBAL iconalign=horizontal ");
      TwDefine(" GLOBAL contained=true ");
      TwDefine(" GLOBAL buttonalign=right");
      TwDefine(" GLOBAL fontsize=3");
      TwDefine(" GLOBAL fontresizable=false");
      TwDefine(" TW_HELP visible=false ");
      *cursorX_=-1e10f;
      *cursorY_=-1e10f;
      *cursorLastX_=-1e10f;
      *cursorLastY_=-1e10f;

      set_theme(DARK);
    }
Exemple #2
0
/*
 * Setup for color display
 */
static void color_setup(const char *theme)
{
	int use_color;

	use_color = set_theme(theme);
	if (use_color && has_colors()) {
		start_color();
		init_dialog_colors();
	} else
		set_mono_theme();
}
Exemple #3
0
UISystem::~UISystem()
{
  OverlayManager::destroyInstance();

  // finish theme
  set_theme(nullptr, guiscale());

  details::exitWidgets();

  _internal_set_mouse_display(nullptr);
  if (!update_custom_native_cursor(nullptr))
    update_mouse_overlay(nullptr);

  ASSERT(g_instance == this);
  g_instance = nullptr;
}
Exemple #4
0
ProjectManager::ProjectManager() {

	int margin = get_constant("margin","Dialogs");
	int button_margin = get_constant("button_margin","Dialogs");

	// load settings
	if (!EditorSettings::get_singleton())
		EditorSettings::create();


	set_area_as_parent_rect();
	Panel *panel = memnew( Panel );
	add_child(panel);
	panel->set_area_as_parent_rect();

	VBoxContainer *vb = memnew( VBoxContainer );
	panel->add_child(vb);
	vb->set_area_as_parent_rect(20);


	Label *l = memnew( Label );
	l->set_text(_MKSTR(VERSION_NAME)" - Project Manager");
	l->add_font_override("font",get_font("large","Fonts"));
	l->set_align(Label::ALIGN_CENTER);
	vb->add_child(l);
	l = memnew( Label );
	l->set_text("v"VERSION_MKSTRING);
	//l->add_font_override("font",get_font("bold","Fonts"));
	l->set_align(Label::ALIGN_CENTER);
	vb->add_child(l);
	vb->add_child(memnew(HSeparator));
	vb->add_margin_child("\n",memnew(Control));


	HBoxContainer *tree_hb = memnew( HBoxContainer);
	vb->add_margin_child("Recent Projects:",tree_hb,true);

	PanelContainer *pc = memnew( PanelContainer);
	pc->add_style_override("panel",get_stylebox("bg","Tree"));
	tree_hb->add_child(pc);
	pc->set_h_size_flags(SIZE_EXPAND_FILL);

	scroll = memnew( ScrollContainer );
	pc->add_child(scroll);
	scroll->set_enable_h_scroll(false);

	VBoxContainer *tree_vb = memnew( VBoxContainer);
	tree_hb->add_child(tree_vb);	
	scroll_childs = memnew( VBoxContainer );
	scroll_childs->set_h_size_flags(SIZE_EXPAND_FILL);
	scroll->add_child(scroll_childs);

	//HBoxContainer *hb = memnew( HBoxContainer );
	//vb->add_child(hb);

	Button *open = memnew( Button );
	open->set_text("Edit");
	tree_vb->add_child(open);
	open->connect("pressed", this,"_open_project");
	open_btn=open;

	Button *run = memnew( Button );
	run->set_text("Run");
	tree_vb->add_child(run);
	run->connect("pressed", this,"_run_project");
	run_btn=run;

	tree_vb->add_child(memnew( HSeparator ));

	Button *scan = memnew( Button );
	scan->set_text("Scan");
	tree_vb->add_child(scan);
	scan->connect("pressed", this,"_scan_projects");

	tree_vb->add_child(memnew( HSeparator ));

	scan_dir = memnew( FileDialog );
	scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM);
	scan_dir->set_mode(FileDialog::MODE_OPEN_DIR);
	add_child(scan_dir);
	scan_dir->connect("dir_selected",this,"_scan_begin");


	Button* create = memnew( Button );
	create->set_text("New Project");
	tree_vb->add_child(create);
	create->connect("pressed", this,"_new_project");

	Button* import = memnew( Button );
	import->set_text("Import");
	tree_vb->add_child(import);
	import->connect("pressed", this,"_import_project");


	Button* erase = memnew( Button );
	erase->set_text("Erase");
	tree_vb->add_child(erase);
	erase->connect("pressed", this,"_erase_project");
	erase_btn=erase;


	tree_vb->add_spacer();

	Button * cancel = memnew( Button );
	cancel->set_text("Exit");
	tree_vb->add_child(cancel);
	cancel->connect("pressed", this,"_exit_dialog");


	vb->add_margin_child("\n",memnew(Control));
	vb->add_child(memnew(HSeparator));

	l = memnew( Label );
	String cp;
	cp.push_back(0xA9);
	cp.push_back(0);
	l->set_text(cp+" 2008-2012 Juan Linietsky, Ariel Manzur.");
	l->set_align(Label::ALIGN_CENTER);
	vb->add_child(l);


	erase_ask = memnew( ConfirmationDialog );
	erase_ask->get_ok()->set_text("Erase");
	erase_ask->get_ok()->connect("pressed", this,"_erase_project_confirm");

	add_child(erase_ask);

	OS::get_singleton()->set_low_processor_usage_mode(true);

	npdialog = memnew( NewProjectDialog );
	add_child(npdialog);

	Ref<Theme> theme = memnew( Theme );
	editor_register_icons(theme);
	set_theme(theme);

	npdialog->connect("project_created", this,"_load_recent_projects");
	_load_recent_projects();
	//get_ok()->set_text("Open");
	//get_ok()->set_text("Exit");

}
Exemple #5
0
bool GridMap::_set(const StringName &p_name, const Variant &p_value) {

	String name = p_name;

	if (name == "theme") {

		set_theme(p_value);
	} else if (name == "cell_size") {
		set_cell_size(p_value);
	} else if (name == "cell_octant_size") {
		set_octant_size(p_value);
	} else if (name == "cell_center_x") {
		set_center_x(p_value);
	} else if (name == "cell_center_y") {
		set_center_y(p_value);
	} else if (name == "cell_center_z") {
		set_center_z(p_value);
	} else if (name == "cell_scale") {
		set_cell_scale(p_value);
		/*	} else if (name=="cells") {
		PoolVector<int> cells = p_value;
		int amount=cells.size();
		PoolVector<int>::Read r = cells.read();
		ERR_FAIL_COND_V(amount&1,false); // not even
		cell_map.clear();
		for(int i=0;i<amount/3;i++) {


			IndexKey ik;
			ik.key=decode_uint64(&r[i*3]);
			Cell cell;
			cell.cell=uint32_t(r[i*+1]);
			cell_map[ik]=cell;

		}
		_recreate_octant_data();*/
	} else if (name == "data") {

		Dictionary d = p_value;

		if (d.has("cells")) {

			PoolVector<int> cells = d["cells"];
			int amount = cells.size();
			PoolVector<int>::Read r = cells.read();
			ERR_FAIL_COND_V(amount % 3, false); // not even
			cell_map.clear();
			for (int i = 0; i < amount / 3; i++) {

				IndexKey ik;
				ik.key = decode_uint64((const uint8_t *)&r[i * 3]);
				Cell cell;
				cell.cell = decode_uint32((const uint8_t *)&r[i * 3 + 2]);
				cell_map[ik] = cell;
			}
		}
		_recreate_octant_data();

	} else if (name.begins_with("areas/")) {
		int which = name.get_slicec('/', 1).to_int();
		String what = name.get_slicec('/', 2);
		if (what == "bounds") {
			ERR_FAIL_COND_V(area_map.has(which), false);
			create_area(which, p_value);
			return true;
		}

		ERR_FAIL_COND_V(!area_map.has(which), false);

		if (what == "name")
			area_set_name(which, p_value);
		else if (what == "disable_distance")
			area_set_portal_disable_distance(which, p_value);
		else if (what == "exterior_portal")
			area_set_portal_disable_color(which, p_value);
		else
			return false;
	} else
		return false;

	return true;
}
InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
	set_name("Inspector");
	set_theme(p_editor->get_gui_base()->get_theme());

	editor = p_editor;
	editor_data = &p_editor_data;

	HBoxContainer *general_options_hb = memnew(HBoxContainer);
	add_child(general_options_hb);

	resource_new_button = memnew(ToolButton);
	resource_new_button->set_tooltip(TTR("Create a new resource in memory and edit it."));
	resource_new_button->set_icon(get_icon("New", "EditorIcons"));
	general_options_hb->add_child(resource_new_button);
	resource_new_button->connect("pressed", this, "_new_resource");
	resource_new_button->set_focus_mode(Control::FOCUS_NONE);

	resource_load_button = memnew(ToolButton);
	resource_load_button->set_tooltip(TTR("Load an existing resource from disk and edit it."));
	resource_load_button->set_icon(get_icon("Load", "EditorIcons"));
	general_options_hb->add_child(resource_load_button);
	resource_load_button->connect("pressed", this, "_open_resource_selector");
	resource_load_button->set_focus_mode(Control::FOCUS_NONE);

	general_options_hb->add_spacer();

	backward_button = memnew(ToolButton);
	general_options_hb->add_child(backward_button);
	backward_button->set_icon(get_icon("Back", "EditorIcons"));
	backward_button->set_flat(true);
	backward_button->set_tooltip(TTR("Go to the previous edited object in history."));
	backward_button->set_disabled(true);
	backward_button->connect("pressed", this, "_edit_back");

	forward_button = memnew(ToolButton);
	general_options_hb->add_child(forward_button);
	forward_button->set_icon(get_icon("Forward", "EditorIcons"));
	forward_button->set_flat(true);
	forward_button->set_tooltip(TTR("Go to the next edited object in history."));
	forward_button->set_disabled(true);
	forward_button->connect("pressed", this, "_edit_forward");

	history_menu = memnew(MenuButton);
	history_menu->set_tooltip(TTR("History of recently edited objects."));
	history_menu->set_icon(get_icon("History", "EditorIcons"));
	general_options_hb->add_child(history_menu);
	history_menu->connect("about_to_show", this, "_prepare_history");
	history_menu->get_popup()->connect("id_pressed", this, "_select_history");

	HBoxContainer *node_info_hb = memnew(HBoxContainer);
	add_child(node_info_hb);

	editor_path = memnew(EditorPath(editor->get_editor_history()));
	editor_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	node_info_hb->add_child(editor_path);

	object_menu = memnew(MenuButton);
	object_menu->set_icon(get_icon("Tools", "EditorIcons"));
	node_info_hb->add_child(object_menu);
	object_menu->set_tooltip(TTR("Object properties."));
	object_menu->get_popup()->connect("id_pressed", this, "_menu_option");

	new_resource_dialog = memnew(CreateDialog);
	editor->get_gui_base()->add_child(new_resource_dialog);
	new_resource_dialog->set_base_type("Resource");
	new_resource_dialog->connect("create", this, "_resource_created");

	search = memnew(LineEdit);
	search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
	search->set_placeholder(TTR("Filter properties"));
	search->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
	add_child(search);

	warning = memnew(Button);
	add_child(warning);
	warning->set_text(TTR("Changes may be lost!"));
	warning->set_icon(get_icon("NodeWarning", "EditorIcons"));
	warning->hide();
	warning->connect("pressed", this, "_warning_pressed");

	warning_dialog = memnew(AcceptDialog);
	editor->get_gui_base()->add_child(warning_dialog);

	load_resource_dialog = memnew(EditorFileDialog);
	add_child(load_resource_dialog);
	load_resource_dialog->set_current_dir("res://");
	load_resource_dialog->connect("file_selected", this, "_resource_file_selected");

	inspector = memnew(EditorInspector);
	add_child(inspector);
	inspector->set_autoclear(true);
	inspector->set_show_categories(true);
	inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
	inspector->set_use_doc_hints(true);
	inspector->set_hide_script(false);
	inspector->set_enable_capitalize_paths(bool(EDITOR_GET("interface/inspector/capitalize_properties")));
	inspector->set_use_folding(!bool(EDITOR_GET("interface/inspector/disable_folding")));
	inspector->register_text_enter(search);
	inspector->set_undo_redo(&editor_data->get_undo_redo());

	inspector->set_use_filter(true); // TODO: check me

	inspector->connect("resource_selected", this, "_resource_selected");
	inspector->connect("property_keyed", this, "_property_keyed");
}
Exemple #7
0
bool GridMap::_set(const StringName &p_name, const Variant &p_value) {

	String name = p_name;

	if (name == "theme") {

		set_theme(p_value);
	} else if (name == "cell_size") {
		if (p_value.get_type() == Variant::INT || p_value.get_type() == Variant::REAL) {
			//compatibility
			float cs = p_value;
			set_cell_size(Vector3(cs, cs, cs));
		} else {
			set_cell_size(p_value);
		}
	} else if (name == "cell_octant_size") {
		set_octant_size(p_value);
	} else if (name == "cell_center_x") {
		set_center_x(p_value);
	} else if (name == "cell_center_y") {
		set_center_y(p_value);
	} else if (name == "cell_center_z") {
		set_center_z(p_value);
	} else if (name == "cell_scale") {
		set_cell_scale(p_value);
		/*	} else if (name=="cells") {
		PoolVector<int> cells = p_value;
		int amount=cells.size();
		PoolVector<int>::Read r = cells.read();
		ERR_FAIL_COND_V(amount&1,false); // not even
		cell_map.clear();
		for(int i=0;i<amount/3;i++) {


			IndexKey ik;
			ik.key=decode_uint64(&r[i*3]);
			Cell cell;
			cell.cell=uint32_t(r[i*+1]);
			cell_map[ik]=cell;

		}
		_recreate_octant_data();*/
	} else if (name == "data") {

		Dictionary d = p_value;

		if (d.has("cells")) {

			PoolVector<int> cells = d["cells"];
			int amount = cells.size();
			PoolVector<int>::Read r = cells.read();
			ERR_FAIL_COND_V(amount % 3, false); // not even
			cell_map.clear();
			for (int i = 0; i < amount / 3; i++) {

				IndexKey ik;
				ik.key = decode_uint64((const uint8_t *)&r[i * 3]);
				Cell cell;
				cell.cell = decode_uint32((const uint8_t *)&r[i * 3 + 2]);
				cell_map[ik] = cell;
			}
		}
		_recreate_octant_data();

	} else
		return false;

	return true;
}
Exemple #8
0
ProjectManager::ProjectManager() {

	// load settings
	if (!EditorSettings::get_singleton())
		EditorSettings::create();


	EditorSettings::get_singleton()->set_optimize_save(false); //just write settings as they came

	{
		int dpi_mode = EditorSettings::get_singleton()->get("global/hidpi_mode");
		if (dpi_mode==0) {
			editor_set_scale( OS::get_singleton()->get_screen_dpi(0) > 150 && OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x>2000 ? 2.0 : 1.0 );
		} else if (dpi_mode==1) {
			editor_set_scale(0.75);
		} else if (dpi_mode==2) {
			editor_set_scale(1.0);
		} else if (dpi_mode==3) {
			editor_set_scale(1.5);
		} else if (dpi_mode==4) {
			editor_set_scale(2.0);
		}
	}

	FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));

	set_area_as_parent_rect();
	set_theme(create_editor_theme());

	gui_base = memnew( Control );
	add_child(gui_base);
	gui_base->set_area_as_parent_rect();
	gui_base->set_theme(create_custom_theme());

	Panel *panel = memnew( Panel );
	gui_base->add_child(panel);
	panel->set_area_as_parent_rect();

	VBoxContainer *vb = memnew( VBoxContainer );
	panel->add_child(vb);
	vb->set_area_as_parent_rect(20*EDSCALE);
	vb->set_margin(MARGIN_TOP,4*EDSCALE);
	vb->set_margin(MARGIN_BOTTOM,4*EDSCALE);
	vb->add_constant_override("separation",15*EDSCALE);

	String cp;
	cp.push_back(0xA9);
	cp.push_back(0);
	OS::get_singleton()->set_window_title(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager")+" - "+cp+" 2008-2016 Juan Linietsky, Ariel Manzur.");

	HBoxContainer *top_hb = memnew( HBoxContainer);
	vb->add_child(top_hb);
	CenterContainer *ccl = memnew( CenterContainer );
	Label *l = memnew( Label );
	l->set_text(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager"));
	l->add_font_override("font", gui_base->get_font("doc","EditorFonts"));
	ccl->add_child(l);
	top_hb->add_child(ccl);
	top_hb->add_spacer();
	l = memnew( Label );
	l->set_text("v" VERSION_MKSTRING);
	//l->add_font_override("font",get_font("bold","Fonts"));
	l->set_align(Label::ALIGN_CENTER);
	top_hb->add_child(l);
	//vb->add_child(memnew(HSeparator));
	//vb->add_margin_child("\n",memnew(Control));

	tabs = memnew( TabContainer );
	vb->add_child(tabs);
	tabs->set_v_size_flags(SIZE_EXPAND_FILL);

	HBoxContainer *tree_hb = memnew( HBoxContainer);
	projects_hb = tree_hb;

	projects_hb->set_name(TTR("Project List"));

	tabs->add_child(tree_hb);

	VBoxContainer *search_tree_vb = memnew(VBoxContainer);
	search_tree_vb->set_h_size_flags(SIZE_EXPAND_FILL);
	tree_hb->add_child(search_tree_vb);

	HBoxContainer *search_box = memnew(HBoxContainer);
	search_box->add_spacer(true);
	project_filter = memnew(ProjectListFilter);
	search_box->add_child(project_filter);
	project_filter->connect("filter_changed", this, "_load_recent_projects");
	project_filter->set_custom_minimum_size(Size2(250,10));
	search_tree_vb->add_child(search_box);

	PanelContainer *pc = memnew( PanelContainer);
	pc->add_style_override("panel", gui_base->get_stylebox("bg","Tree"));
	search_tree_vb->add_child(pc);
	pc->set_v_size_flags(SIZE_EXPAND_FILL);

	scroll = memnew( ScrollContainer );
	pc->add_child(scroll);
	scroll->set_enable_h_scroll(false);

	VBoxContainer *tree_vb = memnew( VBoxContainer);
	tree_hb->add_child(tree_vb);
	scroll_childs = memnew( VBoxContainer );
	scroll_childs->set_h_size_flags(SIZE_EXPAND_FILL);
	scroll->add_child(scroll_childs);

	//HBoxContainer *hb = memnew( HBoxContainer );
	//vb->add_child(hb);

	Button *open = memnew( Button );
	open->set_text(TTR("Edit"));
	tree_vb->add_child(open);
	open->connect("pressed", this,"_open_project");
	open_btn=open;

	Button *run = memnew( Button );
	run->set_text(TTR("Run"));
	tree_vb->add_child(run);
	run->connect("pressed", this,"_run_project");
	run_btn=run;

	tree_vb->add_child(memnew( HSeparator ));

	Button *scan = memnew( Button );
	scan->set_text(TTR("Scan"));
	tree_vb->add_child(scan);
	scan->connect("pressed", this,"_scan_projects");

	tree_vb->add_child(memnew( HSeparator ));

	scan_dir = memnew( FileDialog );
	scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM);
	scan_dir->set_mode(FileDialog::MODE_OPEN_DIR);
	scan_dir->set_title(TTR("Select a Folder to Scan")); // must be after mode or it's overridden
	scan_dir->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_path") );
	gui_base->add_child(scan_dir);
	scan_dir->connect("dir_selected",this,"_scan_begin");


	Button* create = memnew( Button );
	create->set_text(TTR("New Project"));
	tree_vb->add_child(create);
	create->connect("pressed", this,"_new_project");

	Button* import = memnew( Button );
	import->set_text(TTR("Import"));
	tree_vb->add_child(import);
	import->connect("pressed", this,"_import_project");


	Button* erase = memnew( Button );
	erase->set_text(TTR("Remove"));
	tree_vb->add_child(erase);
	erase->connect("pressed", this,"_erase_project");
	erase_btn=erase;


	tree_vb->add_spacer();


	if (StreamPeerSSL::is_available()) {
		asset_library = memnew( EditorAssetLibrary(true) );
		asset_library->set_name("Templates");
		tabs->add_child(asset_library);
		asset_library->connect("install_asset",this,"_install_project");
	} else {
		WARN_PRINT("Asset Library not available, as it requires SSL to work.");
	}


	CenterContainer *cc = memnew( CenterContainer );
	Button * cancel = memnew( Button );
	cancel->set_text(TTR("Exit"));
	cancel->set_custom_minimum_size(Size2(100,1)*EDSCALE);
	cc->add_child(cancel);
	cancel->connect("pressed", this,"_exit_dialog");
	vb->add_child(cc);

	//

	erase_ask = memnew( ConfirmationDialog );
	erase_ask->get_ok()->set_text(TTR("Remove"));
	erase_ask->get_ok()->connect("pressed", this,"_erase_project_confirm");

	gui_base->add_child(erase_ask);

	multi_open_ask = memnew( ConfirmationDialog );
	multi_open_ask->get_ok()->set_text(TTR("Edit"));
	multi_open_ask->get_ok()->connect("pressed", this, "_open_project_confirm");

	gui_base->add_child(multi_open_ask);

	multi_run_ask = memnew( ConfirmationDialog );
	multi_run_ask->get_ok()->set_text(TTR("Run"));
	multi_run_ask->get_ok()->connect("pressed", this, "_run_project_confirm");

	gui_base->add_child(multi_run_ask);

	multi_scan_ask = memnew( ConfirmationDialog );
	multi_scan_ask->get_ok()->set_text(TTR("Scan"));

	gui_base->add_child(multi_scan_ask);

	OS::get_singleton()->set_low_processor_usage_mode(true);

	npdialog = memnew( NewProjectDialog );
	gui_base->add_child(npdialog);

	npdialog->connect("project_created", this,"_load_recent_projects");
	_load_recent_projects();

	if ( EditorSettings::get_singleton()->get("global/autoscan_project_path") ) {
		_scan_begin( EditorSettings::get_singleton()->get("global/autoscan_project_path") );
	}

	//get_ok()->set_text("Open");
	//get_ok()->set_text("Exit");

	last_clicked = "";

	SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped");
}
Exemple #9
0
ProjectManager::ProjectManager() {

	int margin = get_constant("margin","Dialogs");
	int button_margin = get_constant("button_margin","Dialogs");

	// load settings
	if (!EditorSettings::get_singleton())
		EditorSettings::create();

	FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));

	set_area_as_parent_rect();

	Ref<Theme> theme = Ref<Theme>( memnew( Theme ) );
	set_theme(theme);
	editor_register_icons(theme);

	String global_font = EditorSettings::get_singleton()->get("global/font");
	if (global_font!="") {
		Ref<Font> fnt = ResourceLoader::load(global_font);
		if (fnt.is_valid()) {
			theme->set_default_theme_font(fnt);
		}
	}

	Panel *panel = memnew( Panel );
	add_child(panel);
	panel->set_area_as_parent_rect();

	VBoxContainer *vb = memnew( VBoxContainer );
	panel->add_child(vb);
	vb->set_area_as_parent_rect(20);

	OS::get_singleton()->set_window_title(_MKSTR(VERSION_NAME)" - Project Manager");

	Label *l = memnew( Label );
	l->set_text(_MKSTR(VERSION_NAME)" - Project Manager");
	l->add_font_override("font",get_font("large","Fonts"));
	l->set_align(Label::ALIGN_CENTER);
	vb->add_child(l);
	l = memnew( Label );
	l->set_text("v" VERSION_MKSTRING);
	//l->add_font_override("font",get_font("bold","Fonts"));
	l->set_align(Label::ALIGN_CENTER);
	vb->add_child(l);
	vb->add_child(memnew(HSeparator));
	vb->add_margin_child("\n",memnew(Control));


	HBoxContainer *tree_hb = memnew( HBoxContainer);
	vb->add_margin_child("Recent Projects:",tree_hb,true);

	VBoxContainer *search_tree_vb = memnew(VBoxContainer);
	search_tree_vb->set_h_size_flags(SIZE_EXPAND_FILL);
	tree_hb->add_child(search_tree_vb);

	HBoxContainer *search_box = memnew(HBoxContainer);
	search_box->add_spacer(true);
	project_filter = memnew(ProjectListFilter);
	search_box->add_child(project_filter);
	project_filter->connect("filter_changed", this, "_load_recent_projects");
	project_filter->set_custom_minimum_size(Size2(250,10));
	search_tree_vb->add_child(search_box);

	PanelContainer *pc = memnew( PanelContainer);
	pc->add_style_override("panel",get_stylebox("bg","Tree"));
	search_tree_vb->add_child(pc);
	pc->set_v_size_flags(SIZE_EXPAND_FILL);

	scroll = memnew( ScrollContainer );
	pc->add_child(scroll);
	scroll->set_enable_h_scroll(false);

	VBoxContainer *tree_vb = memnew( VBoxContainer);
	tree_hb->add_child(tree_vb);
	scroll_childs = memnew( VBoxContainer );
	scroll_childs->set_h_size_flags(SIZE_EXPAND_FILL);
	scroll->add_child(scroll_childs);

	//HBoxContainer *hb = memnew( HBoxContainer );
	//vb->add_child(hb);

	Button *open = memnew( Button );
	open->set_text("Edit");
	tree_vb->add_child(open);
	open->connect("pressed", this,"_open_project");
	open_btn=open;

	Button *run = memnew( Button );
	run->set_text("Run");
	tree_vb->add_child(run);
	run->connect("pressed", this,"_run_project");
	run_btn=run;

	tree_vb->add_child(memnew( HSeparator ));

	Button *scan = memnew( Button );
	scan->set_text("Scan");
	tree_vb->add_child(scan);
	scan->connect("pressed", this,"_scan_projects");

	tree_vb->add_child(memnew( HSeparator ));

	scan_dir = memnew( FileDialog );
	scan_dir->set_access(FileDialog::ACCESS_FILESYSTEM);
	scan_dir->set_mode(FileDialog::MODE_OPEN_DIR);
	scan_dir->set_current_dir( EditorSettings::get_singleton()->get("global/default_project_path") );
	add_child(scan_dir);
	scan_dir->connect("dir_selected",this,"_scan_begin");


	Button* create = memnew( Button );
	create->set_text("New Project");
	tree_vb->add_child(create);
	create->connect("pressed", this,"_new_project");

	Button* import = memnew( Button );
	import->set_text("Import");
	tree_vb->add_child(import);
	import->connect("pressed", this,"_import_project");


	Button* erase = memnew( Button );
	erase->set_text("Erase");
	tree_vb->add_child(erase);
	erase->connect("pressed", this,"_erase_project");
	erase_btn=erase;


	tree_vb->add_spacer();

	Button * cancel = memnew( Button );
	cancel->set_text("Exit");
	tree_vb->add_child(cancel);
	cancel->connect("pressed", this,"_exit_dialog");


	vb->add_margin_child("\n",memnew(Control));
	vb->add_child(memnew(HSeparator));

	l = memnew( Label );
	String cp;
	cp.push_back(0xA9);
	cp.push_back(0);
	l->set_text(cp+" 2008-2015 Juan Linietsky, Ariel Manzur.");
	l->set_align(Label::ALIGN_CENTER);
	vb->add_child(l);


	erase_ask = memnew( ConfirmationDialog );
	erase_ask->get_ok()->set_text("Erase");
	erase_ask->get_ok()->connect("pressed", this,"_erase_project_confirm");

	add_child(erase_ask);

	multi_open_ask = memnew( ConfirmationDialog );
	multi_open_ask->get_ok()->set_text("Edit");
	multi_open_ask->get_ok()->connect("pressed", this, "_open_project_confirm");

	add_child(multi_open_ask);

	multi_run_ask = memnew( ConfirmationDialog );
	multi_run_ask->get_ok()->set_text("Run");
	multi_run_ask->get_ok()->connect("pressed", this, "_run_project_confirm");

	add_child(multi_run_ask);

	OS::get_singleton()->set_low_processor_usage_mode(true);

	npdialog = memnew( NewProjectDialog );
	add_child(npdialog);

	npdialog->connect("project_created", this,"_load_recent_projects");
	_load_recent_projects();

	if ( EditorSettings::get_singleton()->get("global/autoscan_project_path") ) {
		_scan_begin( EditorSettings::get_singleton()->get("global/autoscan_project_path") );
	}

	//get_ok()->set_text("Open");
	//get_ok()->set_text("Exit");

	last_clicked = "";
}
// Read from Settings file Function
void
read_s_file() {
	if (ensure_path_mounted("/sdcard") != 0) {
		LOGI("=> Can not mount /sdcard, running on default settings\n"); // Can't mount sdcard, default settings should be unchanged.
	} else {
		FILE *fp; // define file
		fp = fopen(TW_SETTINGS_FILE, "r"); // Open file for read
		if (fp == NULL) {
			LOGI("=> Can not open settings file, will try to create file.\n"); // Can't open file, default settings should be unchanged.
			write_s_file(); // call save settings function if settings file doesn't exist
		} else {
			int i = 0;
			int len;
			char s_line[TW_MAX_SETTINGS_CHARS+2]; // Set max characters + 2 (because of terminating and carriage return)
			while(i < TW_MAX_NUM_SETTINGS) {
				fgets(s_line, TW_MAX_SETTINGS_CHARS+2, fp); // Read a line from file
				len = strlen(s_line); // get length of line
				if (s_line[len-1] == '\n') { // if last char is carriage return
					s_line[len-1] = 0; // remove it by setting it to 0
				}
				if (i == TW_VERSION) {
					if (strcmp(s_line,tw_version_val) != 0) {
						LOGI("=> Wrong recoverywin version detected, default settings applied.\n"); //
						tw_set_defaults();
						write_s_file();
						break;
					}
				} else if (i == TW_NAN_SYSTEM) {
			    	strcpy(tw_nan_system_val, s_line);
                } else if (i == TW_NAN_DATA) {
			    	strcpy(tw_nan_data_val, s_line);
				} else if (i == TW_NAN_BOOT) {
			    	strcpy(tw_nan_boot_val, s_line);
				} else if (i == TW_NAN_RECOVERY) {
			    	strcpy(tw_nan_recovery_val, s_line);
				} else if (i == TW_NAN_CACHE) {
			    	strcpy(tw_nan_cache_val, s_line);
				} else if (i == TW_NAN_WIMAX) {
			    	strcpy(tw_nan_wimax_val, s_line);
				} else if (i == TW_NAN_ANDSEC) {
			    	strcpy(tw_nan_andsec_val, s_line);
				} else if (i == TW_NAN_SDEXT) {
			    	strcpy(tw_nan_sdext_val, s_line);
				} else if (i == TW_REBOOT_AFTER_FLASH) {
			    	strcpy(tw_reboot_after_flash_option, s_line);
				} else if (i == TW_SIGNED_ZIP) {
			    	strcpy(tw_signed_zip_val, s_line);
			    } else if (i == TW_COLOR_THEME) {
			    	strcpy(tw_color_theme_val, s_line);
			    } else if (i == TW_USE_COMPRESSION) {
			    	strcpy(tw_use_compression_val, s_line);
				} else if (i == TW_TIME_ZONE) {
			    	strcpy(tw_time_zone_val, s_line);
				} else if (i == TW_ZIP_LOCATION) {
			    	strcpy(tw_zip_location_val, s_line);
				} 
				i++; // increment loop
			}
			fclose(fp); // close file
		}
	}
	update_tz_environment_variables();
	set_theme(tw_color_theme_val);
}
Exemple #11
0
void
on_main_reset_button_clicked           (GtkButton       *button,
                                        gpointer         user_data)
{
	set_theme(get_orig_theme(), get_orig_font());
}
void twrp_themes_menu()
{
    const char* MENU_THEMES_HEADERS[] = {  "twrp Theme Chooser",
    								   	   "Taste tEh Rainbow:",
                                           NULL };
    
	char* MENU_THEMES[] =       { 	"[RESTART MENU AND APPLY THEME]",
									checkTheme(TW_THEME),
									checkTheme(CM_THEME),
									checkTheme(RED_THEME),
									checkTheme(GOOGLE_THEME),
									checkTheme(JF_THEME),
									checkTheme(HTC_THEME),
									checkTheme(FABULOUS_THEME),
									checkTheme(PURPLE_SHIFT),
									checkTheme(GREYBALLER_THEME),
									checkTheme(TRIPPY_THEME),
									checkTheme(SHIFTY_BASTARD),
									checkTheme(MYN_WARM),
									"<-- Back To twrp Settings",
									NULL };

    char** headers = prepend_title(MENU_THEMES_HEADERS);
    
    inc_menu_loc(THEMES_BACK);
    for (;;)
    {
        int chosen_item = get_menu_selection(headers, MENU_THEMES, 0, 0);
        switch (chosen_item)
        {
            case THEME_REBOOT_RECOVERY:
				set_theme(DataManager_GetStrValue(TW_COLOR_THEME_VAR));
				go_home = 1;
				go_restart = 1;
                break;
            case TW_THEME:
            	DataManager_SetIntValue(TW_COLOR_THEME_VAR, 0);
                break;
            case CM_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 1);
                break;
            case RED_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 2);
                break;
            case GOOGLE_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 3);
                break;
            case JF_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 4);
                break;
            case HTC_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 5);
                break;
            case FABULOUS_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 6);
                break;
			case PURPLE_SHIFT:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 7);
                break;
			case GREYBALLER_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 8);
                break;
			case TRIPPY_THEME:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 9);
                break;
			case SHIFTY_BASTARD:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 10);
                break;
			case MYN_WARM:
                DataManager_SetIntValue(TW_COLOR_THEME_VAR, 11);
                break;
            case THEMES_BACK:
            	dec_menu_loc();
            	return;
        }
        if (go_home) {
        	dec_menu_loc();
	        return;
	    }
        break;
    }
	ui_end_menu();
    dec_menu_loc();
    twrp_themes_menu();
}