コード例 #1
0
ファイル: settings.cpp プロジェクト: nem0/LumixEngine
int Settings::getValue(const char* name, int default_value) const
{
	lua_getglobal(m_state, "custom");
	int v = getIntegerField(m_state, name, default_value);
	lua_pop(m_state, 1);
	return v;
}
コード例 #2
0
ファイル: settings.cpp プロジェクト: zemanmar/LumixEngine
bool Settings::load(Action** actions, int actions_count)
{
	lua_State* L = luaL_newstate();
	luaL_openlibs(L);

	bool errors = luaL_loadfile(L, SETTINGS_PATH) != LUA_OK;
	errors = errors || lua_pcall(L, 0, LUA_MULTRET, 0) != LUA_OK;
	if (errors)
	{
		Lumix::g_log_error.log("lua") << SETTINGS_PATH << ": " << lua_tostring(L, -1);
		lua_pop(L, 1);
		return false;
	}

	if (lua_getglobal(L, "window") == LUA_TTABLE)
	{
		m_window.x = getIntegerField(L, "x", 0);
		m_window.y = getIntegerField(L, "y", 0);
		m_window.w = getIntegerField(L, "w", -1);
		m_window.h = getIntegerField(L, "h", -1);
	}
	lua_pop(L, 1);

	m_is_maximized = getBoolean(L, "maximized", true);
	
	m_is_opened = getBoolean(L, "settings_opened", false);
	m_is_asset_browser_opened = getBoolean(L, "asset_browser_opened", false);
	m_is_entity_list_opened = getBoolean(L, "entity_list_opened", false);
	m_is_entity_template_list_opened = getBoolean(L, "entity_template_list_opened", false);
	m_is_gameview_opened = getBoolean(L, "gameview_opened", false);
	m_is_hierarchy_opened = getBoolean(L, "hierarchy_opened", false);
	m_is_log_opened = getBoolean(L, "log_opened", false);
	m_is_profiler_opened = getBoolean(L, "profiler_opened", false);
	m_is_properties_opened = getBoolean(L, "properties_opened", false);
	m_is_style_editor_opened = getBoolean(L, "style_editor_opened", false);
	m_is_shader_editor_opened = getBoolean(L, "shader_editor_opened", false);
	m_is_clip_manager_opened = getBoolean(L, "clip_manager_opened", false);
	m_is_crash_reporting_enabled = getBoolean(L, "error_reporting_enabled", true);
	Lumix::enableCrashReporting(m_is_crash_reporting_enabled);
	m_autosave_time = getInteger(L, "autosave_time", 300);

	if (lua_getglobal(L, "actions") == LUA_TTABLE)
	{
		for (int i = 0; i < actions_count; ++i)
		{
			if (lua_getfield(L, -1, actions[i]->name) == LUA_TTABLE)
			{
				for (int j = 0; j < Lumix::lengthOf(actions[i]->shortcut); ++j)
				{
					if (lua_rawgeti(L, -1, 1 + j) == LUA_TNUMBER)
					{
						actions[i]->shortcut[j] = (int)lua_tointeger(L, -1);
					}
					lua_pop(L, 1);
				}
			}
			lua_pop(L, 1);
		}
	}
	lua_pop(L, 1);

	lua_close(L);
	return true;
}
コード例 #3
0
ファイル: settings.cpp プロジェクト: nem0/LumixEngine
bool Settings::load()
{
	auto L = m_state;
	bool has_settings = PlatformInterface::fileExists(SETTINGS_PATH);
	bool errors = luaL_loadfile(L, has_settings ? SETTINGS_PATH : DEFAULT_SETTINGS_PATH) != LUA_OK;
	errors = errors || lua_pcall(L, 0, 0, 0) != LUA_OK;
	if (errors)
	{
		g_log_error.log("Editor") << SETTINGS_PATH << ": " << lua_tostring(L, -1);
		lua_pop(L, 1);
		return false;
	}

	if (lua_getglobal(L, "window") == LUA_TTABLE)
	{
		m_window.x = getIntegerField(L, "x", 0);
		m_window.y = getIntegerField(L, "y", 0);
		m_window.w = getIntegerField(L, "w", -1);
		m_window.h = getIntegerField(L, "h", -1);
	}
	lua_pop(L, 1);

	loadStyle(L);

	m_is_maximized = getBoolean(L, "maximized", true);
	
	m_is_open = getBoolean(L, "settings_opened", false);
	m_is_asset_browser_open = getBoolean(L, "asset_browser_opened", false);
	m_asset_browser_left_column_width = getFloat(L, "asset_browser_left_column_width", false);
	m_is_entity_list_open = getBoolean(L, "entity_list_opened", false);
	m_is_entity_template_list_open = getBoolean(L, "entity_template_list_opened", false);
	m_is_log_open = getBoolean(L, "log_opened", false);
	m_is_profiler_open = getBoolean(L, "profiler_opened", false);
	m_is_properties_open = getBoolean(L, "properties_opened", false);
	m_is_crash_reporting_enabled = getBoolean(L, "error_reporting_enabled", true);
	enableCrashReporting(m_is_crash_reporting_enabled && !m_force_no_crash_report);
	m_mouse_sensitivity.x = getFloat(L, "mouse_sensitivity_x", 200.0f);
	m_mouse_sensitivity.y = getFloat(L, "mouse_sensitivity_y", 200.0f);
	m_font_size = getInteger(L, "font_size", 13);

	if (!m_editor->getEngine().getPatchFileDevice())
	{
		if (lua_getglobal(L, "data_dir") == LUA_TSTRING) copyString(m_data_dir, lua_tostring(L, -1));
		lua_pop(L, 1);
		m_editor->getEngine().setPatchPath(m_data_dir);
	}

	auto& actions = m_app.getActions();
	if (lua_getglobal(L, "actions") == LUA_TTABLE)
	{
		for (int i = 0; i < actions.size(); ++i)
		{
			if (lua_getfield(L, -1, actions[i]->name) == LUA_TTABLE)
			{
				for (int j = 0; j < lengthOf(actions[i]->shortcut); ++j)
				{
					if (lua_rawgeti(L, -1, 1 + j) == LUA_TNUMBER)
					{
						actions[i]->shortcut[j] = (int)lua_tointeger(L, -1);
					}
					lua_pop(L, 1);
				}
			}
			lua_pop(L, 1);
		}
	}
	lua_pop(L, 1);

	m_app.getToolbarActions().clear();
	if (lua_getglobal(L, "toolbar") == LUA_TTABLE)
	{
		int len = (int)lua_rawlen(L, -1);
		for (int i = 0; i < len; ++i)
		{
			if (lua_rawgeti(L, -1, i + 1) == LUA_TSTRING)
			{
				const char* action_name = lua_tostring(L, -1);
				Action* action = m_app.getAction(action_name);
				if(action) m_app.getToolbarActions().push(action);
			}
			lua_pop(L, 1);
		}
	}
	lua_pop(L, 1);

	ImGui::LoadDock(L);
	return true;
}
コード例 #4
0
w_void jdwp_threadgrp_children(jdwp_command_packet cmd) {
  w_instance  threadgroup;
  w_size offset = 0;
  w_instance  threads_vector;
  w_instance  groups_vector;
  w_instance  threads_array;
  w_instance  groups_array;
  w_instance  *threads_data = NULL;
  w_instance  *groups_data = NULL;
  w_int       threads_count = 0;
  w_int       groups_count = 0;
  w_int       i;
  
  threadgroup = jdwp_get_objectref(cmd->data, &offset);
  woempa(7, "ThreadGroup = %j\n", threadgroup);
  if (threadgroup) {
    if (isSuperClass(clazzThreadGroup, instance2clazz(threadgroup))) {
      threads_vector = getReferenceField(threadgroup, F_ThreadGroup_flock);
      groups_vector =  getReferenceField(threadgroup, F_ThreadGroup_children);

      /*
      ** Get the number of elements in the 2 vectors.
      */

      if(threads_vector) {
        threads_count = getIntegerField(threads_vector, F_Vector_elementCount);
        threads_array = getReferenceField(threads_vector, F_Vector_elementData);
        threads_data = instance2Array_instance(threads_array);
      } 

      if(groups_vector) {
        groups_count =  getIntegerField(groups_vector, F_Vector_elementCount);
        groups_array = getReferenceField(groups_vector, F_Vector_elementData);
        groups_data = instance2Array_instance(groups_array);
      }

      // childThreads
      woempa(7, "Child threads: %d\n", threads_count);
      // HACK - if this is the system thread group, ignore the JDWP thread
      jdwp_put_u4(&reply_grobag, (w_word)(threads_count - (threadgroup == I_ThreadGroup_system)));
      for(i = 0; i < threads_count; i++) {
        if (getWotsitField(threads_data[i], F_Thread_wotsit) != jdwp_thread) {
          woempa(7, "  %j\n", threads_data[i]);
          jdwp_put_objectref(&reply_grobag, threads_data[i]);
        }
        else {
          woempa(7, "  skipping %j\n", threads_data[i]);
        }
      }

      // childGroups
      woempa(7, "Child groups: %d\n", groups_count);
      jdwp_put_u4(&reply_grobag, (w_word)groups_count);
      for(i = 0; i < groups_count; i++) {
        woempa(7, "  %j\n", groups_data[i]);
        jdwp_put_objectref(&reply_grobag, groups_data[i]);
      }

      jdwp_send_reply(cmd->id, &reply_grobag, jdwp_err_none);
    }
    else {
      jdwp_send_invalid_thread_group(cmd->id);
    }
  }
  else {
    jdwp_send_invalid_object(cmd->id);
  }
}