static int _mainloop(struct skynet_context * context, void * ud, int type, int session, uint32_t source, const void * msg, size_t sz) { if (type == PTYPE_SOCKET) { dispatch_socket((struct master *)ud, (const skynet_socket_message *)msg, (int)sz); return 0; } if (type != PTYPE_HARBOR) { skynet_error(context, "None harbor message recv from %x (type = %d)", source, type); return 0; } assert(sz >= 4); struct master *m = (struct master*)ud; const uint8_t *handlen = (const uint8_t *)msg; uint32_t handle = handlen[0]<<24 | handlen[1]<<16 | handlen[2]<<8 | handlen[3]; sz -= 4; const char * name = (const char *)msg; name += 4; if (handle == 0) { _request_name(m , name, sz); } else if (handle < REMOTE_MAX) { _update_address(m , handle, name, sz); } else { _update_name(m , handle, name, sz); } return 0; }
void ResourcesDock::_file_action(const String& p_path) { switch(current_action) { case TOOL_OPEN: { } break; case TOOL_SAVE: case TOOL_SAVE_AS: { TreeItem *ti = resources->get_selected(); if (!ti) break; Ref<Resource> current_res = ti->get_metadata(0); RES res(current_res); save_resource(p_path,res); _update_name(ti); } break; } }
void ScriptTextEditor::_notification(int p_what) { if (p_what==NOTIFICATION_READY) { _update_name(); } }
void ScriptTextEditor::set_edited_script(const Ref<Script>& p_script) { ERR_FAIL_COND(!script.is_null()); script=p_script; _load_theme_settings(); get_text_edit()->set_text(script->get_source_code()); get_text_edit()->clear_undo_history(); get_text_edit()->tag_saved_version(); _update_name(); _line_col_changed(); }
void ResourcesDock::add_resource(const Ref<Resource>& p_resource) { if (block_add) return; if (!p_resource.is_valid()) return; TreeItem *root = resources->get_root(); ERR_FAIL_COND(!root); TreeItem *existing=root->get_children(); while(existing) { Ref<Resource> r = existing->get_metadata(0); if (r==p_resource) { //existing->move_to_top(); existing->select(0); resources->ensure_cursor_is_visible(); return; // existing } existing=existing->get_next(); } TreeItem *res = resources->create_item(root); res->set_metadata(0,p_resource); if (has_icon(p_resource->get_type(),"EditorIcons")) { res->set_icon(0,get_icon(p_resource->get_type(),"EditorIcons")); } _update_name(res); res->add_button(0,get_icon("Del","EditorIcons")); res->move_to_top(); res->select(0); resources->ensure_cursor_is_visible(); }
static int _mainloop(struct skynet_context * context, void * ud, int type, int session, uint32_t source, const void * msg, size_t sz) { if (type != PTYPE_HARBOR) { skynet_error(context, "None harbor message recv from %x (type = %d)", source, type); return 0; } struct master *m = ud; uint32_t handle = 0; memcpy(&handle, msg, 4); handle = ntohl(handle); sz -= 4; const char * name = msg; name += 4; if (handle == 0) { _request_name(context, m , name, sz); } else if (handle < REMOTE_MAX) { _update_address(context, m , handle, name, sz); } else { _update_name(context, m , handle, name, sz); } return 0; }
void ScriptTextEditor::_validate_script() { String errortxt; int line=-1,col; TextEdit *te=get_text_edit(); String text = te->get_text(); List<String> fnc; if (!script->get_language()->validate(text,line,col,errortxt,script->get_path(),&fnc)) { String error_text="error("+itos(line)+","+itos(col)+"): "+errortxt; set_error(error_text); } else { set_error(""); line=-1; if (!script->is_tool()) { script->set_source_code(text); script->update_exports(); //script->reload(); //will update all the variables in property editors } functions.clear(); for (List<String>::Element *E=fnc.front();E;E=E->next()) { functions.push_back(E->get()); } } line--; for(int i=0;i<te->get_line_count();i++) { te->set_line_as_marked(i,line==i); } _update_name(); }
void ResourcesDock::_tool_selected(int p_tool) { current_action=p_tool; switch(p_tool) { case TOOL_NEW: { create_dialog->popup_centered_ratio(); } break; case TOOL_OPEN: { editor->open_resource(); } break; case TOOL_SAVE: { TreeItem *ti = resources->get_selected(); if (!ti) break; Ref<Resource> current_res = ti->get_metadata(0); if (current_res->get_path()!="" && current_res->get_path().find("::")==-1) { _file_action(current_res->get_path()); break; }; }; /* fallthrough */ case TOOL_SAVE_AS: { TreeItem *ti = resources->get_selected(); if (!ti) break; save_resource_as(ti->get_metadata(0)); } break; case TOOL_MAKE_LOCAL: { TreeItem *ti = resources->get_selected(); if (!ti) break; Ref<Resource> current_res = ti->get_metadata(0); current_res->set_path(""); _update_name(ti); } break; case TOOL_COPY: { TreeItem *ti = resources->get_selected(); if (!ti) break; Ref<Resource> current_res = ti->get_metadata(0); EditorSettings::get_singleton()->set_resource_clipboard(current_res); } break; case TOOL_PASTE: { add_resource(EditorSettings::get_singleton()->get_resource_clipboard()); } break; } }
void ResourcesDock::_tool_selected(int p_tool) { current_action=p_tool; switch(p_tool) { case TOOL_NEW: { create_dialog->popup_centered_ratio(); } break; case TOOL_OPEN: { editor->open_resource(); } break; case TOOL_SAVE: { TreeItem *ti = resources->get_selected(); if (!ti) break; Ref<Resource> current_res = ti->get_metadata(0); if (current_res->get_path()!="" && current_res->get_path().find("::")==-1) { _file_action(current_res->get_path()); break; }; }; /* fallthrough */ case TOOL_SAVE_AS: { TreeItem *ti = resources->get_selected(); if (!ti) break; Ref<Resource> current_res = ti->get_metadata(0); RES res(current_res); List<String> extensions; ResourceSaver::get_recognized_extensions(res,&extensions); file->set_mode(FileDialog::MODE_SAVE_FILE); //not for now? if (current_res->get_path()!="" && current_res->get_path().find("::")==-1) { file->set_current_path(current_res->get_path()); } else { String existing; if (extensions.size()) { existing="new_"+res->get_type().to_lower()+"."+extensions.front()->get().to_lower(); } file->set_current_file(existing); } file->clear_filters(); for(int i=0;i<extensions.size();i++) { file->add_filter("*."+extensions[i]+" ; "+extensions[i].to_upper()); } //file->set_current_path(current_path); file->popup_centered_ratio(); } break; case TOOL_MAKE_LOCAL: { TreeItem *ti = resources->get_selected(); if (!ti) break; Ref<Resource> current_res = ti->get_metadata(0); current_res->set_path(""); _update_name(ti); } break; case TOOL_COPY: { TreeItem *ti = resources->get_selected(); if (!ti) break; Ref<Resource> current_res = ti->get_metadata(0); EditorSettings::get_singleton()->set_resource_clipboard(current_res); } break; case TOOL_PASTE: { add_resource(EditorSettings::get_singleton()->get_resource_clipboard()); } break; } }