forked from Mirrorlandia_minetest/minetest
Add video driver selection to settings menu (based uppon idea from webdesigner97)
This commit is contained in:
parent
26f4a5c110
commit
996ea60642
@ -110,6 +110,24 @@ local function scrollbar_to_gui_scale(value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function formspec(tabview, name, tabdata)
|
local function formspec(tabview, name, tabdata)
|
||||||
|
local video_drivers = core.get_video_drivers()
|
||||||
|
|
||||||
|
local video_driver_string = ""
|
||||||
|
local current_video_driver_idx = 0
|
||||||
|
local current_video_driver = core.setting_get("video_driver")
|
||||||
|
for i=1, #video_drivers, 1 do
|
||||||
|
|
||||||
|
if i ~= 1 then
|
||||||
|
video_driver_string = video_driver_string .. ","
|
||||||
|
end
|
||||||
|
video_driver_string = video_driver_string .. video_drivers[i]
|
||||||
|
|
||||||
|
if current_video_driver:lower() == video_drivers[i]:lower() then
|
||||||
|
current_video_driver_idx = i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local tab_string =
|
local tab_string =
|
||||||
"vertlabel[0,-0.25;" .. fgettext("SETTINGS") .. "]" ..
|
"vertlabel[0,-0.25;" .. fgettext("SETTINGS") .. "]" ..
|
||||||
"box[0.75,0;3.25,4;#999999]" ..
|
"box[0.75,0;3.25,4;#999999]" ..
|
||||||
@ -125,6 +143,10 @@ local function formspec(tabview, name, tabdata)
|
|||||||
.. dump(core.setting_getbool("preload_item_visuals")) .. "]"..
|
.. dump(core.setting_getbool("preload_item_visuals")) .. "]"..
|
||||||
"checkbox[1,2.5;cb_particles;".. fgettext("Enable Particles") .. ";"
|
"checkbox[1,2.5;cb_particles;".. fgettext("Enable Particles") .. ";"
|
||||||
.. dump(core.setting_getbool("enable_particles")) .. "]"..
|
.. dump(core.setting_getbool("enable_particles")) .. "]"..
|
||||||
|
"dropdown[1,3.25;3;dd_video_driver;"
|
||||||
|
.. video_driver_string .. ";" .. current_video_driver_idx .. "]" ..
|
||||||
|
"tooltip[dd_video_driver;" ..
|
||||||
|
fgettext("Restart minetest for driver change to take effect") .. "]" ..
|
||||||
"box[4.25,0;3.25,2.5;#999999]" ..
|
"box[4.25,0;3.25,2.5;#999999]" ..
|
||||||
"checkbox[4.5,0;cb_mipmapping;".. fgettext("Mip-Mapping") .. ";"
|
"checkbox[4.5,0;cb_mipmapping;".. fgettext("Mip-Mapping") .. ";"
|
||||||
.. dump(core.setting_getbool("mip_map")) .. "]"..
|
.. dump(core.setting_getbool("mip_map")) .. "]"..
|
||||||
@ -284,16 +306,20 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields["btn_reset_singleplayer"] then
|
if fields["btn_reset_singleplayer"] then
|
||||||
print("sp reset")
|
|
||||||
showconfirm_reset(this)
|
showconfirm_reset(this)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
--Note dropdowns have to be handled LAST!
|
--Note dropdowns have to be handled LAST!
|
||||||
local ddhandled = false
|
local ddhandled = false
|
||||||
if fields["dd_touchthreshold"] then
|
if fields["dd_touchthreshold"] then
|
||||||
core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"])
|
core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"])
|
||||||
ddhandled = true
|
ddhandled = true
|
||||||
end
|
end
|
||||||
|
if fields["dd_video_driver"] then
|
||||||
|
core.setting_set("video_driver",fields["dd_video_driver"])
|
||||||
|
ddhandled = true
|
||||||
|
end
|
||||||
|
|
||||||
return ddhandled
|
return ddhandled
|
||||||
end
|
end
|
||||||
|
@ -88,6 +88,9 @@ core.sound_play(spec, looped) -> handle
|
|||||||
^ spec = SimpleSoundSpec (see lua-api.txt)
|
^ spec = SimpleSoundSpec (see lua-api.txt)
|
||||||
^ looped = bool
|
^ looped = bool
|
||||||
core.sound_stop(handle)
|
core.sound_stop(handle)
|
||||||
|
core.get_video_drivers()
|
||||||
|
^ get list of video drivers supported by engine (not all modes are guaranteed to work)
|
||||||
|
^ returns list of available video drivers e.g. { "OpenGL", "Software" }
|
||||||
|
|
||||||
Formspec:
|
Formspec:
|
||||||
core.update_formspec(formspec)
|
core.update_formspec(formspec)
|
||||||
|
54
src/main.cpp
54
src/main.cpp
@ -1365,41 +1365,43 @@ int main(int argc, char *argv[])
|
|||||||
u16 fsaa = g_settings->getU16("fsaa");
|
u16 fsaa = g_settings->getU16("fsaa");
|
||||||
|
|
||||||
// Determine driver
|
// Determine driver
|
||||||
|
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
|
||||||
video::E_DRIVER_TYPE driverType;
|
static const char* driverids[] = {
|
||||||
|
"null",
|
||||||
std::string driverstring = g_settings->get("video_driver");
|
"software",
|
||||||
|
"burningsvideo",
|
||||||
if (driverstring == "null")
|
"direct3d8",
|
||||||
driverType = video::EDT_NULL;
|
"direct3d9",
|
||||||
else if (driverstring == "software")
|
"opengl"
|
||||||
driverType = video::EDT_SOFTWARE;
|
|
||||||
else if (driverstring == "burningsvideo")
|
|
||||||
driverType = video::EDT_BURNINGSVIDEO;
|
|
||||||
else if (driverstring == "direct3d8")
|
|
||||||
driverType = video::EDT_DIRECT3D8;
|
|
||||||
else if (driverstring == "direct3d9")
|
|
||||||
driverType = video::EDT_DIRECT3D9;
|
|
||||||
else if (driverstring == "opengl")
|
|
||||||
driverType = video::EDT_OPENGL;
|
|
||||||
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
#ifdef _IRR_COMPILE_WITH_OGLES1_
|
||||||
else if (driverstring == "ogles1")
|
,"ogles1"
|
||||||
driverType = video::EDT_OGLES1;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||||
else if (driverstring == "ogles2")
|
,"ogles2"
|
||||||
driverType = video::EDT_OGLES2;
|
|
||||||
#endif
|
#endif
|
||||||
else {
|
,"invalid"
|
||||||
errorstream << "WARNING: Invalid video_driver specified; defaulting "
|
};
|
||||||
<< "to opengl" << std::endl;
|
|
||||||
driverType = video::EDT_OPENGL;
|
std::string driverstring = g_settings->get("video_driver");
|
||||||
|
for (unsigned int i = 0;
|
||||||
|
i < (sizeof(driverids)/sizeof(driverids[0]));
|
||||||
|
i++)
|
||||||
|
{
|
||||||
|
if (strcasecmp(driverstring.c_str(), driverids[i]) == 0) {
|
||||||
|
driverType = (video::E_DRIVER_TYPE) i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp("invalid", driverids[i]) == 0) {
|
||||||
|
errorstream << "WARNING: Invalid video_driver specified; defaulting "
|
||||||
|
<< "to opengl" << std::endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
List video modes if requested
|
List video modes if requested
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MyEventReceiver* receiver = new MyEventReceiver();
|
MyEventReceiver* receiver = new MyEventReceiver();
|
||||||
|
|
||||||
if (cmd_args.getFlag("videomodes")) {
|
if (cmd_args.getFlag("videomodes")) {
|
||||||
|
@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "main.h" // for g_settings
|
#include "main.h" // for g_settings
|
||||||
|
#include "EDriverTypes.h"
|
||||||
|
|
||||||
#include <IFileArchive.h>
|
#include <IFileArchive.h>
|
||||||
#include <IFileSystem.h>
|
#include <IFileSystem.h>
|
||||||
@ -1001,6 +1002,36 @@ int ModApiMainMenu::l_download_file(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
int ModApiMainMenu::l_get_video_drivers(lua_State *L)
|
||||||
|
{
|
||||||
|
static const char* drivernames[] = {
|
||||||
|
"NULL Driver",
|
||||||
|
"Software",
|
||||||
|
"Burningsvideo",
|
||||||
|
"Direct3D 8",
|
||||||
|
"Direct3D 9",
|
||||||
|
"OpenGL",
|
||||||
|
"OGLES1",
|
||||||
|
"OGLES2"
|
||||||
|
};
|
||||||
|
unsigned int index = 1;
|
||||||
|
lua_newtable(L);
|
||||||
|
int top = lua_gettop(L);
|
||||||
|
|
||||||
|
for (unsigned int i = irr::video::EDT_SOFTWARE;
|
||||||
|
i < MYMIN(irr::video::EDT_COUNT, (sizeof(drivernames)/sizeof(drivernames[0])));
|
||||||
|
i++) {
|
||||||
|
if (irr::IrrlichtDevice::isDriverSupported((irr::video::E_DRIVER_TYPE) i)) {
|
||||||
|
lua_pushnumber(L,index++);
|
||||||
|
lua_pushstring(L,drivernames[i]);
|
||||||
|
lua_settable(L, top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
int ModApiMainMenu::l_gettext(lua_State *L)
|
int ModApiMainMenu::l_gettext(lua_State *L)
|
||||||
{
|
{
|
||||||
@ -1094,6 +1125,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
|
|||||||
API_FCT(sound_play);
|
API_FCT(sound_play);
|
||||||
API_FCT(sound_stop);
|
API_FCT(sound_stop);
|
||||||
API_FCT(gettext);
|
API_FCT(gettext);
|
||||||
|
API_FCT(get_video_drivers);
|
||||||
API_FCT(get_screen_info);
|
API_FCT(get_screen_info);
|
||||||
API_FCT(do_async_callback);
|
API_FCT(do_async_callback);
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,8 @@ private:
|
|||||||
|
|
||||||
static int l_download_file(lua_State *L);
|
static int l_download_file(lua_State *L);
|
||||||
|
|
||||||
|
static int l_get_video_drivers(lua_State *L);
|
||||||
|
|
||||||
// async
|
// async
|
||||||
static int l_do_async_callback(lua_State *L);
|
static int l_do_async_callback(lua_State *L);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user