Index: ps/trunk/build/premake/premake4.lua =================================================================== --- ps/trunk/build/premake/premake4.lua (revision 14495) +++ ps/trunk/build/premake/premake4.lua (revision 14496) @@ -1,1437 +1,1440 @@ newoption { trigger = "android", description = "Use non-working Android cross-compiling mode" } newoption { trigger = "atlas", description = "Include Atlas scenario editor projects" } newoption { trigger = "collada", description = "Include COLLADA projects (requires FCollada library)" } newoption { trigger = "coverage", description = "Enable code coverage data collection (GCC only)" } newoption { trigger = "gles", description = "Use non-working OpenGL ES 2.0 mode" } newoption { trigger = "icc", description = "Use Intel C++ Compiler (Linux only; should use either \"--cc icc\" or --without-pch too, and then set CXX=icpc before calling make)" } newoption { trigger = "outpath", description = "Location for generated project files" } newoption { trigger = "without-audio", description = "Disable use of OpenAL/Ogg/Vorbis APIs" } newoption { trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed. Has no effect on Windows builds" } newoption { trigger = "without-nvtt", description = "Disable use of NVTT" } newoption { trigger = "without-tests", description = "Disable generation of test projects" } newoption { trigger = "without-pch", description = "Disable generation and usage of precompiled headers" } newoption { trigger = "without-lobby", description = "Disable the use of gloox and the multiplayer lobby" } newoption { trigger = "without-miniupnpc", description = "Disable use of miniupnpc for port forwarding" } newoption { trigger = "with-system-nvtt", description = "Search standard paths for nvidia-texture-tools library, instead of using bundled copy" } newoption { trigger = "with-system-enet", description = "Search standard paths for libenet, instead of using bundled copy" } newoption { trigger = "with-system-miniupnpc", description = "Search standard paths for libminiupnpc, instead of using bundled copy" } newoption { trigger = "with-system-mozjs185", description = "Search standard paths for libmozjs185, instead of using bundled copy" } newoption { trigger = "with-c++11", description = "Enable C++11 on GCC" } newoption { trigger = "sysroot", description = "Set compiler system root path, used for building against a non-system SDK. For example /usr/local becomes SYSROOT/user/local" } newoption { trigger = "macosx-version-min", description = "Set minimum required version of the OS X API, the build will possibly fail if an older SDK is used, while newer API functions will be weakly linked (i.e. resolved at runtime)" } newoption { trigger = "macosx-bundle", description = "Enable OSX bundle, the argument is the bundle identifier string (e.g. com.wildfiregames.0ad)" } newoption { trigger = "build-shared-glooxwrapper", description = "Rebuild glooxwrapper DLL for Windows. Requires the same compiler version that gloox was built with" } newoption { trigger = "use-shared-glooxwrapper", description = "Use prebuilt glooxwrapper DLL for Windows" } newoption { trigger = "bindir", description = "Directory for executables (typically '/usr/games'); default is to be relocatable" } newoption { trigger = "datadir", description = "Directory for data files (typically '/usr/share/games/0ad'); default is ../data/ relative to executable" } newoption { trigger = "libdir", description = "Directory for libraries (typically '/usr/lib/games/0ad'); default is ./ relative to executable" } -- Root directory of project checkout relative to this .lua file rootdir = "../.." dofile("extern_libs4.lua") -- detect CPU architecture (simplistic, currently only supports x86, amd64 and ARM) arch = "x86" if _OPTIONS["android"] then arch = "arm" elseif os.is("windows") then if os.getenv("PROCESSOR_ARCHITECTURE") == "amd64" or os.getenv("PROCESSOR_ARCHITEW6432") == "amd64" then arch = "amd64" end else arch = os.getenv("HOSTTYPE") if arch == "x86_64" or arch == "amd64" then arch = "amd64" else os.execute("gcc -dumpmachine > .gccmachine.tmp") local f = io.open(".gccmachine.tmp", "r") local machine = f:read("*line") f:close() if string.find(machine, "x86_64") == 1 or string.find(machine, "amd64") == 1 then arch = "amd64" elseif string.find(machine, "i.86") == 1 then arch = "x86" elseif string.find(machine, "arm") == 1 then arch = "arm" else print("WARNING: Cannot determine architecture from GCC, assuming x86") end end end -- Set up the Solution solution "pyrogenesis" targetdir(rootdir.."/binaries/system") libdirs(rootdir.."/binaries/system") if not _OPTIONS["outpath"] then error("You must specify the 'outpath' parameter") end location(_OPTIONS["outpath"]) configurations { "Release", "Debug" } -- Get some environement specific information used later. if os.is("windows") then nasmpath(rootdir.."/build/bin/nasm.exe") lcxxtestpath = rootdir.."/build/bin/cxxtestgen.exe" has_broken_pch = false else lcxxtestpath = rootdir.."/build/bin/cxxtestgen.pl" if os.is("linux") and arch == "amd64" then nasmformat "elf64" elseif os.is("macosx") and arch == "amd64" then nasmformat "macho64" elseif os.is("macosx") then nasmformat "macho" else nasmformat "elf" end -- GCC bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10591) - PCH breaks anonymous namespaces -- Fixed in 4.2.0, but we have to disable PCH for earlier versions, else -- it conflicts annoyingly with wx 2.8 headers. -- It's too late to do this test by the time we start compiling the PCH file, so -- do the test in this build script instead (which is kind of ugly - please fix if -- you have a better idea) if not _OPTIONS["icc"] then os.execute("gcc -dumpversion > .gccver.tmp") local f = io.open(".gccver.tmp", "r") major, dot, minor = f:read(1, 1, 1) f:close() major = 0+major -- coerce to number minor = 0+minor has_broken_pch = (major < 4 or (major == 4 and minor < 2)) if has_broken_pch then print("WARNING: Detected GCC <4.2 -- disabling PCH for Atlas (will increase build times)") end end end source_root = rootdir.."/source/" -- default for most projects - overridden by local in others -- Rationale: projects should not have any additional include paths except for -- those required by external libraries. Instead, we should always write the -- full relative path, e.g. #include "maths/Vector3d.h". This avoids confusion -- ("which file is meant?") and avoids enormous include path lists. -- projects: engine static libs, main exe, atlas, atlas frontends, test. -------------------------------------------------------------------------------- -- project helper functions -------------------------------------------------------------------------------- function project_set_target(project_name) -- Note: On Windows, ".exe" is added on the end, on unices the name is used directly local obj_dir_prefix = _OPTIONS["outpath"].."/obj/"..project_name.."_" configuration "Debug" objdir(obj_dir_prefix.."Debug") targetsuffix("_dbg") configuration "Release" objdir(obj_dir_prefix.."Release") configuration { } end function project_set_build_flags() flags { "Symbols", "NoEditAndContinue" } if not _OPTIONS["icc"] and (os.is("windows") or not _OPTIONS["minimal-flags"]) then -- adds the -Wall compiler flag flags { "ExtraWarnings" } -- this causes far too many warnings/remarks on ICC end -- disable Windows debug heap, since it makes malloc/free hugely slower when -- running inside a debugger if os.is("windows") then flags { "NoDebugHeap" } end configuration "Debug" defines { "DEBUG" } configuration "Release" if os.is("windows") or not _OPTIONS["minimal-flags"] then flags { "OptimizeSpeed" } end defines { "NDEBUG", "CONFIG_FINAL=1" } configuration { } if _OPTIONS["gles"] then defines { "CONFIG2_GLES=1" } end if _OPTIONS["without-audio"] then defines { "CONFIG2_AUDIO=0" } end if _OPTIONS["without-nvtt"] then defines { "CONFIG2_NVTT=0" } end if _OPTIONS["without-lobby"] then defines { "CONFIG2_LOBBY=0" } end if _OPTIONS["without-miniupnpc"] then defines { "CONFIG2_MINIUPNPC=0" } end -- required for the lowlevel library. must be set from all projects that use it, otherwise it assumes it is -- being used as a DLL (which is currently not the case in 0ad) defines { "LIB_STATIC_LINK" } -- various platform-specific build flags if os.is("windows") then -- use native wchar_t type (not typedef to unsigned short) flags { "NativeWChar" } flags { "EnableSSE2" } -- Enable SSE2 code generation for VS -- VC++ 2008 has implied FPO as the default (newer versions default to /Oy-) -- disable it explicitly since it breaks our stack walker in release build if _ACTION == "vs2008" then buildoptions { "/Oy-" } end else -- *nix if _OPTIONS["icc"] and not _OPTIONS["minimal-flags"] then buildoptions { "-w1", -- "-Wabi", -- "-Wp64", -- complains about OBJECT_TO_JSVAL which is annoying "-Wpointer-arith", "-Wreturn-type", -- "-Wshadow", "-Wuninitialized", "-Wunknown-pragmas", "-Wunused-function", "-wd1292" -- avoid lots of 'attribute "__nonnull__" ignored' } configuration "Debug" buildoptions { "-O0" } -- ICC defaults to -O2 configuration { } if os.is("macosx") then linkoptions { "-multiply_defined","suppress" } end else -- exclude most non-essential build options for minimal-flags if not _OPTIONS["minimal-flags"] then buildoptions { -- enable most of the standard warnings "-Wno-switch", -- enumeration value not handled in switch (this is sometimes useful, but results in lots of noise) "-Wno-reorder", -- order of initialization list in constructors (lots of noise) "-Wno-invalid-offsetof", -- offsetof on non-POD types (see comment in renderer/PatchRData.cpp) "-Wextra", "-Wno-missing-field-initializers", -- (this is common in external headers we can't fix) -- add some other useful warnings that need to be enabled explicitly "-Wunused-parameter", "-Wredundant-decls", -- (useful for finding some multiply-included header files) -- "-Wformat=2", -- (useful sometimes, but a bit noisy, so skip it by default) -- "-Wcast-qual", -- (useful for checking const-correctness, but a bit noisy, so skip it by default) "-Wnon-virtual-dtor", -- (sometimes noisy but finds real bugs) "-Wundef", -- (useful for finding macro name typos) -- enable security features (stack checking etc) that shouldn't have -- a significant effect on performance and can catch bugs "-fstack-protector-all", "-U_FORTIFY_SOURCE", -- (avoid redefinition warning if already defined) "-D_FORTIFY_SOURCE=2", -- always enable strict aliasing (useful in debug builds because of the warnings) "-fstrict-aliasing", -- don't omit frame pointers (for now), because performance will be impacted -- negatively by the way this breaks profilers more than it will be impacted -- positively by the optimisation "-fno-omit-frame-pointer" } if not _OPTIONS["without-pch"] then buildoptions { -- do something (?) so that ccache can handle compilation with PCH enabled -- (ccache 3.1+ also requires CCACHE_SLOPPINESS=time_macros for this to work) "-fpch-preprocess" } end if arch == "x86" or arch == "amd64" then buildoptions { -- enable SSE intrinsics "-msse" } end if os.is("linux") or os.is("bsd") then linkoptions { "-Wl,--no-undefined", "-Wl,--as-needed" } end if arch == "x86" then buildoptions { -- To support intrinsics like __sync_bool_compare_and_swap on x86 -- we need to set -march to something that supports them "-march=i686" } end end if _OPTIONS["with-c++11"] then buildoptions { -- Enable C++11 standard. VS2010 and higher automatically support C++11 -- but we have to enable it manually on GNU C++ and Intel C++ "-std=c++0x" } end if arch == "arm" then -- disable warnings about va_list ABI change and use -- compile-time flags for futher configuration. buildoptions { "-Wno-psabi" } if _OPTIONS["android"] then -- Android uses softfp, so we should too. buildoptions { "-mfloat-abi=softfp" } end end if _OPTIONS["coverage"] then buildoptions { "-fprofile-arcs", "-ftest-coverage" } links { "gcov" } end -- We don't want to require SSE2 everywhere yet, but OS X headers do -- require it (and Intel Macs always have it) so enable it here if os.is("macosx") then buildoptions { "-msse2" } end -- Check if SDK path should be used if _OPTIONS["sysroot"] then buildoptions { "-isysroot " .. _OPTIONS["sysroot"] } linkoptions { "-Wl,-syslibroot," .. _OPTIONS["sysroot"] } end -- On OS X, sometimes we need to specify the minimum API version to use if _OPTIONS["macosx-version-min"] then buildoptions { "-mmacosx-version-min=" .. _OPTIONS["macosx-version-min"] } -- clang and llvm-gcc look at mmacosx-version-min to determine link target -- and CRT version, and use it to set the macosx_version_min linker flag linkoptions { "-mmacosx-version-min=" .. _OPTIONS["macosx-version-min"] } end -- Check if we're building a bundle if _OPTIONS["macosx-bundle"] then defines { "BUNDLE_IDENTIFIER=" .. _OPTIONS["macosx-bundle"] } end end if not _OPTIONS["minimal-flags"] then buildoptions { -- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with -- Windows - they should be exported explicitly with __attribute__ ((visibility ("default"))) "-fvisibility=hidden" } end if _OPTIONS["bindir"] then defines { "INSTALLED_BINDIR=" .. _OPTIONS["bindir"] } end if _OPTIONS["datadir"] then defines { "INSTALLED_DATADIR=" .. _OPTIONS["datadir"] } end if _OPTIONS["libdir"] then defines { "INSTALLED_LIBDIR=" .. _OPTIONS["libdir"] } end if os.is("linux") or os.is("bsd") then -- To use our local shared libraries, they need to be found in the -- runtime dynamic linker path. Add their path to -rpath. if _OPTIONS["libdir"] then linkoptions {"-Wl,-rpath," .. _OPTIONS["libdir"] } else -- On FreeBSD we need to allow use of $ORIGIN if os.is("bsd") then linkoptions { "-Wl,-z,origin" } end -- Adding the executable path and taking care of correct escaping if _ACTION == "gmake" then linkoptions { "-Wl,-rpath,'$$ORIGIN'" } elseif _ACTION == "codeblocks" then linkoptions { "-Wl,-R\\\\$$ORIGIN" } end end end end end -- add X11 includes paths after all the others so they don't conflict with -- bundled libs function project_add_x11_dirs() if not os.is("windows") and not os.is("macosx") then -- X11 includes may be installed in one of a gadzillion of three places -- Famous last words: "You can't include too much! ;-)" includedirs { "/usr/X11R6/include/X11", "/usr/X11R6/include", "/usr/include/X11" } libdirs { "/usr/X11R6/lib" } end end -- create a project and set the attributes that are common to all projects. function project_create(project_name, target_type) project(project_name) language "C++" kind(target_type) project_set_target(project_name) project_set_build_flags() end -- OSX creates a .app bundle if the project type of the main application is set to "WindowedApp". -- We don't want this because this bundle would be broken (it lacks all the resources and external dependencies, Info.plist etc...) -- Windows opens a console in the background if it's set to ConsoleApp, which is not what we want. -- I didn't check if this setting matters for linux, but WindowedApp works there. function get_main_project_target_type() if _OPTIONS["android"] then return "SharedLib" elseif os.is("macosx") then return "ConsoleApp" else return "WindowedApp" end end -- source_root: rel_source_dirs and rel_include_dirs are relative to this directory -- rel_source_dirs: A table of subdirectories. All source files in these directories are added. -- rel_include_dirs: A table of subdirectories to be included. -- extra_params: table including zero or more of the following: -- * no_pch: If specified, no precompiled headers are used for this project. -- * pch_dir: If specified, this directory will be used for precompiled headers instead of the default -- /pch//. -- * extra_files: table of filenames (relative to source_root) to add to project -- * extra_links: table of library names to add to link step function project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) for i,v in pairs(rel_source_dirs) do local prefix = source_root..v.."/" files { prefix.."*.cpp", prefix.."*.h", prefix.."*.inl", prefix.."*.js", prefix.."*.asm", prefix.."*.mm" } end -- Put the project-specific PCH directory at the start of the -- include path, so '#include "precompiled.h"' will look in -- there first local pch_dir if not extra_params["pch_dir"] then pch_dir = source_root .. "pch/" .. project().name .. "/" else pch_dir = extra_params["pch_dir"] end includedirs { pch_dir } -- Precompiled Headers -- rationale: we need one PCH per static lib, since one global header would -- increase dependencies. To that end, we can either include them as -- "projectdir/precompiled.h", or add "source/PCH/projectdir" to the -- include path and put the PCH there. The latter is better because -- many projects contain several dirs and it's unclear where there the -- PCH should be stored. This way is also a bit easier to use in that -- source files always include "precompiled.h". -- Notes: -- * Visual Assist manages to use the project include path and can -- correctly open these files from the IDE. -- * precompiled.cpp (needed to "Create" the PCH) also goes in -- the abovementioned dir. if (not _OPTIONS["without-pch"] and not extra_params["no_pch"]) then pchheader(pch_dir.."precompiled.h") pchsource(pch_dir.."precompiled.cpp") defines { "USING_PCH" } files { pch_dir.."precompiled.h", pch_dir.."precompiled.cpp" } else flags { "NoPCH" } end -- next is source root dir, for absolute (nonrelative) includes -- (e.g. "lib/precompiled.h") includedirs { source_root } for i,v in pairs(rel_include_dirs) do includedirs { source_root .. v } end if extra_params["extra_files"] then for i,v in pairs(extra_params["extra_files"]) do -- .rc files are only needed on Windows if path.getextension(v) ~= ".rc" or os.is("windows") then files { source_root .. v } end end end if extra_params["extra_links"] then links { extra_params["extra_links"] } end end -- Add command-line options to set up the manifest dependencies for Windows -- (See lib/sysdep/os/win/manifest.cpp) function project_add_manifest() linkoptions { "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df'\"" } configuration "Debug" linkoptions { "\"/manifestdependency:type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50727.4053' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'\"" } configuration "Release" linkoptions { "\"/manifestdependency:type='win32' name='Microsoft.VC80.CRT' version='8.0.50727.4053' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b'\"" } configuration { } end -------------------------------------------------------------------------------- -- engine static libraries -------------------------------------------------------------------------------- -- the engine is split up into several static libraries. this eases separate -- distribution of those components, reduces dependencies a bit, and can -- also speed up builds. -- more to the point, it is necessary to efficiently support a separate -- test executable that also includes much of the game code. -- names of all static libs created. automatically added to the -- main app project later (see explanation at end of this file) static_lib_names = {} static_lib_names_debug = {} static_lib_names_release = {} -- set up one of the static libraries into which the main engine code is split. -- extra_params: -- no_default_link: If specified, linking won't be done by default. -- For the rest of extra_params, see project_add_contents(). -- note: rel_source_dirs and rel_include_dirs are relative to global source_root. function setup_static_lib_project (project_name, rel_source_dirs, extern_libs, extra_params) local target_type = "StaticLib" project_create(project_name, target_type) project_add_contents(source_root, rel_source_dirs, {}, extra_params) project_add_extern_libs(extern_libs, target_type) project_add_x11_dirs() if not extra_params["no_default_link"] then table.insert(static_lib_names, project_name) end if os.is("windows") then flags { "NoRTTI" } end end function setup_shared_lib_project (project_name, rel_source_dirs, extern_libs, extra_params) local target_type = "SharedLib" project_create(project_name, target_type) project_add_contents(source_root, rel_source_dirs, {}, extra_params) project_add_extern_libs(extern_libs, target_type) project_add_x11_dirs() if not extra_params["no_default_link"] then table.insert(static_lib_names, project_name) end if os.is("windows") then flags { "NoRTTI" } links { "delayimp" } end end -- this is where the source tree is chopped up into static libs. -- can be changed very easily; just copy+paste a new setup_static_lib_project, -- or remove existing ones. static libs are automagically added to -- main_exe link step. function setup_all_libs () -- relative to global source_root. local source_dirs = {} -- names of external libraries used (see libraries_dir comment) local extern_libs = {} source_dirs = { "network", } extern_libs = { "spidermonkey", "enet", "boost", -- dragged in via server->simulation.h->random } if not _OPTIONS["without-miniupnpc"] then table.insert(extern_libs, "miniupnpc") end setup_static_lib_project("network", source_dirs, extern_libs, {}) if not _OPTIONS["without-lobby"] then source_dirs = { "lobby", "lobby/scripting", } extern_libs = { "spidermonkey", "boost", "gloox", } setup_static_lib_project("lobby", source_dirs, extern_libs, {}) if _OPTIONS["use-shared-glooxwrapper"] and not _OPTIONS["build-shared-glooxwrapper"] then table.insert(static_lib_names_debug, "glooxwrapper_dbg") table.insert(static_lib_names_release, "glooxwrapper") else source_dirs = { "lobby/glooxwrapper", } extern_libs = { "boost", "gloox", } if _OPTIONS["build-shared-glooxwrapper"] then setup_shared_lib_project("glooxwrapper", source_dirs, extern_libs, {}) else setup_static_lib_project("glooxwrapper", source_dirs, extern_libs, {}) end end else source_dirs = { "lobby/scripting", } extern_libs = { "spidermonkey", "boost" } setup_static_lib_project("lobby", source_dirs, extern_libs, {}) files { source_root.."lobby/Globals.cpp" } end source_dirs = { "simulation2", "simulation2/components", "simulation2/helpers", "simulation2/scripting", "simulation2/serialization", "simulation2/system", "simulation2/testcomponents", } extern_libs = { "boost", "opengl", "spidermonkey", } setup_static_lib_project("simulation2", source_dirs, extern_libs, {}) source_dirs = { "scriptinterface", } extern_libs = { "boost", "spidermonkey", "valgrind", "sdl", } setup_static_lib_project("scriptinterface", source_dirs, extern_libs, {}) source_dirs = { "ps", "ps/scripting", "ps/Network", "ps/GameSetup", "ps/XML", "soundmanager", "soundmanager/data", "soundmanager/items", "soundmanager/scripting", "scripting", "maths", "maths/scripting", } extern_libs = { "spidermonkey", "sdl", -- key definitions "libxml2", "opengl", "zlib", "boost", "enet", "libcurl", } if not _OPTIONS["without-audio"] then table.insert(extern_libs, "openal") table.insert(extern_libs, "vorbis") end setup_static_lib_project("engine", source_dirs, extern_libs, {}) source_dirs = { "graphics", "graphics/scripting", "renderer", "renderer/scripting", "third_party/mikktspace" } extern_libs = { "opengl", "sdl", -- key definitions "spidermonkey", -- for graphics/scripting "boost" } if not _OPTIONS["without-nvtt"] then table.insert(extern_libs, "nvtt") end setup_static_lib_project("graphics", source_dirs, extern_libs, {}) source_dirs = { "tools/atlas/GameInterface", "tools/atlas/GameInterface/Handlers" } extern_libs = { "boost", "sdl", -- key definitions "opengl", "spidermonkey" } setup_static_lib_project("atlas", source_dirs, extern_libs, {}) source_dirs = { "gui", "gui/scripting" } extern_libs = { "spidermonkey", "sdl", -- key definitions "opengl", "boost", } + if not _OPTIONS["without-audio"] then + table.insert(extern_libs, "openal") + end setup_static_lib_project("gui", source_dirs, extern_libs, {}) source_dirs = { "lib", "lib/adts", "lib/allocators", "lib/external_libraries", "lib/file", "lib/file/archive", "lib/file/common", "lib/file/io", "lib/file/vfs", "lib/pch", "lib/posix", "lib/res", "lib/res/graphics", "lib/sysdep", "lib/tex" } extern_libs = { "boost", "sdl", "opengl", "libpng", "zlib", "libjpg", "valgrind", "cxxtest", } -- CPU architecture-specific if arch == "amd64" then table.insert(source_dirs, "lib/sysdep/arch/amd64"); table.insert(source_dirs, "lib/sysdep/arch/x86_x64"); elseif arch == "x86" then table.insert(source_dirs, "lib/sysdep/arch/ia32"); table.insert(source_dirs, "lib/sysdep/arch/x86_x64"); elseif arch == "arm" then table.insert(source_dirs, "lib/sysdep/arch/arm"); end -- OS-specific sysdep_dirs = { linux = { "lib/sysdep/os/linux", "lib/sysdep/os/unix" }, -- note: RC file must be added to main_exe project. -- note: don't add "lib/sysdep/os/win/aken.cpp" because that must be compiled with the DDK. windows = { "lib/sysdep/os/win", "lib/sysdep/os/win/wposix", "lib/sysdep/os/win/whrt" }, macosx = { "lib/sysdep/os/osx", "lib/sysdep/os/unix" }, bsd = { "lib/sysdep/os/bsd", "lib/sysdep/os/unix", "lib/sysdep/os/unix/x" }, } for i,v in pairs(sysdep_dirs[os.get()]) do table.insert(source_dirs, v); end if os.is("linux") then if _OPTIONS["android"] then table.insert(source_dirs, "lib/sysdep/os/android") else table.insert(source_dirs, "lib/sysdep/os/unix/x") end end -- runtime-library-specific if _ACTION == "vs2005" or _ACTION == "vs2008" or _ACTION == "vs2010" or _ACTION == "vs2012" or _ACTION == "vs2013" then table.insert(source_dirs, "lib/sysdep/rtl/msc"); else table.insert(source_dirs, "lib/sysdep/rtl/gcc"); end setup_static_lib_project("lowlevel", source_dirs, extern_libs, {}) -- Third-party libraries that are built as part of the main project, -- not built externally and then linked source_dirs = { "third_party/mongoose", } extern_libs = { } setup_static_lib_project("mongoose", source_dirs, extern_libs, { no_pch = 1 }) -- CxxTest mock function support extern_libs = { "boost", "cxxtest", } -- 'real' implementations, to be linked against the main executable -- (files are added manually and not with setup_static_lib_project -- because not all files in the directory are included) setup_static_lib_project("mocks_real", {}, extern_libs, { no_default_link = 1, no_pch = 1 }) files { "mocks/*.h", source_root.."mocks/*_real.cpp" } -- 'test' implementations, to be linked against the test executable setup_static_lib_project("mocks_test", {}, extern_libs, { no_default_link = 1, no_pch = 1 }) files { source_root.."mocks/*.h", source_root.."mocks/*_test.cpp" } end -------------------------------------------------------------------------------- -- main EXE -------------------------------------------------------------------------------- -- used for main EXE as well as test used_extern_libs = { "opengl", "sdl", "libjpg", "libpng", "zlib", "spidermonkey", "libxml2", "boost", "cxxtest", "comsuppw", "enet", "libcurl", "valgrind", } if not os.is("windows") and not _OPTIONS["android"] and not os.is("macosx") then -- X11 should only be linked on *nix table.insert(used_extern_libs, "x11") table.insert(used_extern_libs, "xcursor") end if not _OPTIONS["without-audio"] then table.insert(used_extern_libs, "openal") table.insert(used_extern_libs, "vorbis") end if not _OPTIONS["without-nvtt"] then table.insert(used_extern_libs, "nvtt") end if not _OPTIONS["without-lobby"] then table.insert(used_extern_libs, "gloox") end if not _OPTIONS["without-miniupnpc"] then table.insert(used_extern_libs, "miniupnpc") end -- Bundles static libs together with main.cpp and builds game executable. function setup_main_exe () local target_type = get_main_project_target_type() project_create("pyrogenesis", target_type) links { "mocks_real" } local extra_params = { extra_files = { "main.cpp" }, no_pch = 1 } project_add_contents(source_root, {}, {}, extra_params) project_add_extern_libs(used_extern_libs, target_type) project_add_x11_dirs() -- Platform Specifics if os.is("windows") then files { source_root.."lib/sysdep/os/win/icon.rc" } -- from "lowlevel" static lib; must be added here to be linked in files { source_root.."lib/sysdep/os/win/error_dialog.rc" } flags { "NoRTTI" } linkoptions { -- wraps main thread in a __try block(see wseh.cpp). replace with mainCRTStartup if that's undesired. "/ENTRY:wseh_EntryPoint", -- see wstartup.h "/INCLUDE:_wstartup_InitAndRegisterShutdown", -- allow manual unload of delay-loaded DLLs "/DELAY:UNLOAD", } -- see manifest.cpp project_add_manifest() elseif os.is("linux") or os.is("bsd") then if not _OPTIONS["android"] and not (os.getversion().description == "OpenBSD") then links { "rt" } end if _OPTIONS["android"] then -- NDK's STANDALONE-TOOLCHAIN.html says this is required linkoptions { "-Wl,--fix-cortex-a8" } links { "log" } end if os.is("linux") or os.getversion().description == "GNU/kFreeBSD" then links { -- Dynamic libraries (needed for linking for gold) "dl", } elseif os.is("bsd") then links { -- Needed for backtrace* on BSDs "execinfo", } end -- Threading support buildoptions { "-pthread" } if not _OPTIONS["android"] then linkoptions { "-pthread" } end -- For debug_resolve_symbol configuration "Debug" linkoptions { "-rdynamic" } configuration { } elseif os.is("macosx") then links { "pthread" } linkoptions { "-framework ApplicationServices", "-framework Cocoa", "-framework CoreFoundation" } end end -------------------------------------------------------------------------------- -- atlas -------------------------------------------------------------------------------- -- setup a typical Atlas component project -- extra_params, rel_source_dirs and rel_include_dirs: as in project_add_contents; function setup_atlas_project(project_name, target_type, rel_source_dirs, rel_include_dirs, extern_libs, extra_params) local source_root = rootdir.."/source/tools/atlas/" .. project_name .. "/" project_create(project_name, target_type) -- if not specified, the default for atlas pch files is in the project root. if not extra_params["pch_dir"] then extra_params["pch_dir"] = source_root end project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) project_add_extern_libs(extern_libs, target_type) project_add_x11_dirs() -- Platform Specifics if os.is("windows") then defines { "_UNICODE" } -- Link to required libraries links { "winmm", "comctl32", "rpcrt4", "delayimp", "ws2_32" } -- required to use WinMain() on Windows, otherwise will default to main() flags { "WinMain" } elseif os.is("linux") or os.is("bsd") then buildoptions { "-rdynamic", "-fPIC" } linkoptions { "-fPIC", "-rdynamic" } elseif os.is("macosx") then -- install_name settings aren't really supported yet by premake, but there are plans for the future. -- we currently use this hack to work around some bugs with wrong install_names. if target_type == "SharedLib" then if _OPTIONS["macosx-bundle"] then -- If we're building a bundle, it will be in ../Frameworks linkoptions { "-install_name @executable_path/../Frameworks/lib"..project_name..".dylib" } else linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" } end end end end -- build all Atlas component projects function setup_atlas_projects() setup_atlas_project("AtlasObject", "StaticLib", { -- src "." },{ -- include },{ -- extern_libs "boost", "libxml2", "spidermonkey", "wxwidgets" },{ -- extra_params no_pch = 1 }) setup_atlas_project("AtlasScript", "StaticLib", { -- src "." },{ -- include ".." },{ -- extern_libs "boost", "spidermonkey", "valgrind", "wxwidgets", },{ -- extra_params no_pch = 1 }) atlas_src = { "ActorEditor", "CustomControls/Buttons", "CustomControls/Canvas", "CustomControls/ColourDialog", "CustomControls/DraggableListCtrl", "CustomControls/EditableListCtrl", "CustomControls/FileHistory", "CustomControls/HighResTimer", "CustomControls/MapDialog", "CustomControls/SnapSplitterWindow", "CustomControls/VirtualDirTreeCtrl", "CustomControls/Windows", "ErrorReporter", "General", "General/VideoRecorder", "Misc", "ScenarioEditor", "ScenarioEditor/Sections/Common", "ScenarioEditor/Sections/Cinematic", "ScenarioEditor/Sections/Environment", "ScenarioEditor/Sections/Map", "ScenarioEditor/Sections/Object", "ScenarioEditor/Sections/Player", "ScenarioEditor/Sections/Terrain", "ScenarioEditor/Sections/Trigger", "ScenarioEditor/Tools", "ScenarioEditor/Tools/Common", } atlas_extra_links = { "AtlasObject", "AtlasScript", } atlas_extern_libs = { "boost", "boost_signals", "comsuppw", --"ffmpeg", -- disabled for now because it causes too many build difficulties "libxml2", "sdl", -- key definitions "spidermonkey", "wxwidgets", "zlib", } if not os.is("windows") and not os.is("macosx") then -- X11 should only be linked on *nix table.insert(atlas_extern_libs, "x11") end setup_atlas_project("AtlasUI", "SharedLib", atlas_src, { -- include "..", "CustomControls", "Misc" }, atlas_extern_libs, { -- extra_params pch_dir = rootdir.."/source/tools/atlas/AtlasUI/Misc/", no_pch = (has_broken_pch), extra_links = atlas_extra_links, extra_files = { "Misc/atlas.rc" } }) end -- Atlas 'frontend' tool-launching projects function setup_atlas_frontend_project (project_name) local target_type = get_main_project_target_type() project_create(project_name, target_type) project_add_extern_libs({ "spidermonkey", }, target_type) project_add_x11_dirs() local source_root = rootdir.."/source/tools/atlas/AtlasFrontends/" files { source_root..project_name..".cpp" } if os.is("windows") then files { source_root..project_name..".rc" } end includedirs { source_root .. ".." } -- Platform Specifics if os.is("windows") then defines { "_UNICODE" } -- required to use WinMain() on Windows, otherwise will default to main() flags { "WinMain" } -- see manifest.cpp project_add_manifest() else -- Non-Windows, = Unix links { "AtlasObject" } end links { "AtlasUI" } end function setup_atlas_frontends() setup_atlas_frontend_project("ActorEditor") end -------------------------------------------------------------------------------- -- collada -------------------------------------------------------------------------------- function setup_collada_project(project_name, target_type, rel_source_dirs, rel_include_dirs, extern_libs, extra_params) project_create(project_name, target_type) local source_root = source_root.."collada/" extra_params["pch_dir"] = source_root project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) project_add_extern_libs(extern_libs, target_type) project_add_x11_dirs() -- Platform Specifics if os.is("windows") then -- required to use WinMain() on Windows, otherwise will default to main() flags { "WinMain" } elseif os.is("linux") then defines { "LINUX" } links { "dl", } -- FCollada is not aliasing-safe, so disallow dangerous optimisations -- (TODO: It'd be nice to fix FCollada, but that looks hard) buildoptions { "-fno-strict-aliasing" } buildoptions { "-rdynamic" } linkoptions { "-rdynamic" } elseif os.is("bsd") then if os.getversion().description == "OpenBSD" then links { "c", } end if os.getversion().description == "GNU/kFreeBSD" then links { "dl", } end buildoptions { "-fno-strict-aliasing" } buildoptions { "-rdynamic" } linkoptions { "-rdynamic" } elseif os.is("macosx") then -- define MACOS-something? -- install_name settings aren't really supported yet by premake, but there are plans for the future. -- we currently use this hack to work around some bugs with wrong install_names. if target_type == "SharedLib" then if _OPTIONS["macosx-bundle"] then -- If we're building a bundle, it will be in ../Frameworks linkoptions { "-install_name @executable_path/../Frameworks/lib"..project_name..".dylib" } else linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" } end end buildoptions { "-fno-strict-aliasing" } -- On OSX, fcollada uses a few utility functions from coreservices linkoptions { "-framework CoreServices" } end end -- build all Collada component projects function setup_collada_projects() setup_collada_project("Collada", "SharedLib", { -- src "." },{ -- include },{ -- extern_libs "fcollada", "libxml2" },{ -- extra_params }) end -------------------------------------------------------------------------------- -- tests -------------------------------------------------------------------------------- -- Cxxtestgen needs to create .cpp files from the .h files before they can be compiled. -- By default we are using prebuildcommands, but we are also using customizations of premake -- for makefiles. The reason is that premake currently has a bug with makefiles and parallel -- builds (e.g. -j5). It's not guaranteed that prebuildcommands always run before building. -- All the *.cpp and *.h files need to be added to files no matter if prebuildcommands -- or customizations are used. -- If no customizations are implemented for a specific action (e.g. vs2010), passing the -- parameters won't have any effects. function configure_cxxtestgen() local lcxxtestrootfile = source_root.."test_root.cpp" files { lcxxtestrootfile } -- Define the options used for cxxtestgen local lcxxtestoptions = "--have-std" local lcxxtestrootoptions = "--have-std" if os.is("windows") then lcxxtestrootoptions = lcxxtestrootoptions .. " --gui=PsTestWrapper --runner=Win32ODSPrinter" else lcxxtestrootoptions = lcxxtestrootoptions .. " --gui=PsTestWrapper --runner=ErrorPrinter" end -- Precompiled headers - the header is added to all generated .cpp files -- note that the header isn't actually precompiled here, only #included -- so that the build stage can use it as a precompiled header. local include = " --include=precompiled.h" lcxxtestrootoptions = lcxxtestrootoptions .. include lcxxtestoptions = lcxxtestoptions .. include -- Set all the parameters used in our cxxtestgen customization in premake. cxxtestrootfile(lcxxtestrootfile) cxxtestpath(lcxxtestpath) cxxtestrootoptions(lcxxtestrootoptions) cxxtestoptions(lcxxtestoptions) -- The file paths needs to be made relative to the project directory for the prebuildcommands. -- premake's paths are relative to premake4.lua by default. lcxxtestrootfile = path.rebase(lcxxtestrootfile, path.getabsolute("."), _OPTIONS["outpath"]) lcxxtestpath = path.rebase(lcxxtestpath, path.getabsolute("."), _OPTIONS["outpath"]) -- On windows we have to use backlashes in our paths. We don't have to take care -- of that for the parameters passed to our cxxtestgen customizations. if os.is("windows") then lcxxtestrootfile = path.translate(lcxxtestrootfile, "\\") lcxxtestpath = path.translate(lcxxtestpath, "\\") end if _ACTION ~= "gmake" and _ACTION ~= "vs2010" and _ACTION ~= "vs2012" and _ACTION ~= "vs2013" then prebuildcommands { lcxxtestpath.." --root "..lcxxtestrootoptions.." -o "..lcxxtestrootfile } end -- Find header files in 'test' subdirectories local all_files = os.matchfiles(source_root .. "**/tests/*.h") for i,v in pairs(all_files) do -- Don't include sysdep tests on the wrong sys -- Don't include Atlas tests unless Atlas is being built if not (string.find(v, "/sysdep/os/win/") and not os.is("windows")) and not (string.find(v, "/tools/atlas/") and not _OPTIONS["atlas"]) and not (string.find(v, "/sysdep/arch/x86_x64/") and ((arch ~= "amd64") or (arch ~= "x86"))) then local src_file = string.sub(v, 1, -3) .. ".cpp" cxxtestsrcfiles { src_file } files { src_file } cxxtesthdrfiles { v } if _ACTION ~= "gmake" and _ACTION ~= "vs2010" and _ACTION ~= "vs2012" and _ACTION ~= "vs2013" then -- see detailed comment above. src_file = path.rebase(src_file, path.getabsolute("."), _OPTIONS["outpath"]) v = path.rebase(v, path.getabsolute("."), _OPTIONS["outpath"]) if os.is("windows") then src_file = path.translate(src_file, "\\") v = path.translate(v, "\\") end prebuildcommands { lcxxtestpath.." --part "..lcxxtestoptions.." -o "..src_file.." "..v } end end end end function setup_tests() local target_type = get_main_project_target_type() project_create("test", target_type) configure_cxxtestgen() links { static_lib_names } configuration "Debug" links { static_lib_names_debug } configuration "Release" links { static_lib_names_release } configuration { } links { "mocks_test" } if _OPTIONS["atlas"] then links { "AtlasObject" } project_add_extern_libs({"wxwidgets"}, target_type) end extra_params = { extra_files = { "test_setup.cpp" }, } project_add_contents(source_root, {}, {}, extra_params) project_add_extern_libs(used_extern_libs, target_type) project_add_x11_dirs() -- TODO: should fix the duplication between this OS-specific linking -- code, and the similar version in setup_main_exe if os.is("windows") then -- from "lowlevel" static lib; must be added here to be linked in files { source_root.."lib/sysdep/os/win/error_dialog.rc" } flags { "NoRTTI" } -- see wstartup.h linkoptions { "/INCLUDE:_wstartup_InitAndRegisterShutdown" } -- Enables console for the TEST project on Windows linkoptions { "/SUBSYSTEM:CONSOLE" } project_add_manifest() elseif os.is("linux") or os.is("bsd") then if not _OPTIONS["android"] and not (os.getversion().description == "OpenBSD") then links { "rt" } end if _OPTIONS["android"] then -- NDK's STANDALONE-TOOLCHAIN.html says this is required linkoptions { "-Wl,--fix-cortex-a8" } end if os.is("linux") or os.getversion().description == "GNU/kFreeBSD" then links { -- Dynamic libraries (needed for linking for gold) "dl", } elseif os.is("bsd") then links { -- Needed for backtrace* on BSDs "execinfo", } end -- Threading support buildoptions { "-pthread" } if not _OPTIONS["android"] then linkoptions { "-pthread" } end -- For debug_resolve_symbol configuration "Debug" linkoptions { "-rdynamic" } configuration { } includedirs { source_root .. "pch/test/" } end end -- must come first, so that VC sets it as the default project and therefore -- allows running via F5 without the "where is the EXE" dialog. setup_main_exe() setup_all_libs() -- add the static libs to the main EXE project. only now (after -- setup_all_libs has run) are the lib names known. cannot move -- setup_main_exe to run after setup_all_libs (see comment above). -- we also don't want to hardcode the names - that would require more -- work when changing the static lib breakdown. project("pyrogenesis") -- Set the main project active links { static_lib_names } configuration "Debug" links { static_lib_names_debug } configuration "Release" links { static_lib_names_release } configuration { } if _OPTIONS["atlas"] then setup_atlas_projects() setup_atlas_frontends() end if _OPTIONS["collada"] then setup_collada_projects() end if not _OPTIONS["without-tests"] then setup_tests() end Index: ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.js (revision 14495) +++ ps/trunk/binaries/data/mods/public/gui/aiconfig/aiconfig.js (revision 14496) @@ -1,54 +1,54 @@ var g_AIs; // [ {"id": ..., "data": {"name": ..., "description": ..., ...} }, ... ] var g_Callback; // for the OK button function init(settings) { g_Callback = settings.callback; g_AIs = [ {id: "", data: {name: "None", description: "AI will be disabled for this player."}} ].concat(settings.ais); - var aiSelection = getGUIObjectByName("aiSelection"); + var aiSelection = Engine.GetGUIObjectByName("aiSelection"); aiSelection.list = [ ai.data.name for each (ai in g_AIs) ]; var selected = 0; for (var i = 0; i < g_AIs.length; ++i) { if (g_AIs[i].id == settings.id) { selected = i; break; } } aiSelection.selected = selected; - var aiDiff = getGUIObjectByName("aiDifficulty"); + var aiDiff = Engine.GetGUIObjectByName("aiDifficulty"); aiDiff.list = [ "Sandbox", "Easy", "Medium", "Hard", "Very Hard" ]; aiDiff.selected = settings.difficulty; } function selectAI(idx) { var id = g_AIs[idx].id; var name = g_AIs[idx].data.name; var description = g_AIs[idx].data.description; - getGUIObjectByName("aiDescription").caption = description; + Engine.GetGUIObjectByName("aiDescription").caption = description; } function returnAI() { - var aiSelection = getGUIObjectByName("aiSelection"); + var aiSelection = Engine.GetGUIObjectByName("aiSelection"); var idx = aiSelection.selected; var id = g_AIs[idx].id; var name = g_AIs[idx].data.name; - var difficulty = getGUIObjectByName("aiDifficulty").selected; + var difficulty = Engine.GetGUIObjectByName("aiDifficulty").selected; // Pop the page before calling the callback, so the callback runs // in the parent GUI page's context Engine.PopGuiPage(); g_Callback({"id": id, "name": name, "difficulty" : difficulty}); } Index: ps/trunk/binaries/data/mods/public/gui/session/menu.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/menu.js (revision 14495) +++ ps/trunk/binaries/data/mods/public/gui/session/menu.js (revision 14496) @@ -1,596 +1,598 @@ const PAUSE = "Pause"; const RESUME = "Resume"; /* * MENU POSITION CONSTANTS */ // Menu / panel border size const MARGIN = 4; // Includes the main menu button const NUM_BUTTONS = 8; // Regular menu buttons const BUTTON_HEIGHT = 32; // The position where the bottom of the menu will end up (currently 228) const END_MENU_POSITION = (BUTTON_HEIGHT * NUM_BUTTONS) + MARGIN; // Menu starting position: bottom const MENU_BOTTOM = 0; // Menu starting position: top const MENU_TOP = MENU_BOTTOM - END_MENU_POSITION; // Menu starting position: overall const INITIAL_MENU_POSITION = "100%-164 " + MENU_TOP + " 100% " + MENU_BOTTOM; // Number of pixels per millisecond to move const MENU_SPEED = 1.2; // Trade menu: available resources and step for probability changes const RESOURCES = ["food", "wood", "stone", "metal"]; const STEP = 5; var isMenuOpen = false; var menu; var isDiplomacyOpen = false; var isTradeOpen = false; // Redefined every time someone makes a tribute (so we can save some data in a closure). Called in input.js handleInputBeforeGui. var flushTributing = function() {}; // Ignore size defined in XML and set the actual menu size here function initMenuPosition() { - menu = getGUIObjectByName("menu"); + menu = Engine.GetGUIObjectByName("menu"); menu.size = INITIAL_MENU_POSITION; } // ============================================================================= // Overall Menu // ============================================================================= // // Slide menu function updateMenuPosition(dt) { if (isMenuOpen) { var maxOffset = END_MENU_POSITION - menu.size.bottom; if (maxOffset > 0) { var offset = Math.min(MENU_SPEED * dt, maxOffset); var size = menu.size; size.top += offset; size.bottom += offset; menu.size = size; } } else { var maxOffset = menu.size.top - MENU_TOP; if (maxOffset > 0) { var offset = Math.min(MENU_SPEED * dt, maxOffset); var size = menu.size; size.top -= offset; size.bottom -= offset; menu.size = size; } } } // Opens the menu by revealing the screen which contains the menu function openMenu() { isMenuOpen = true; } // Closes the menu and resets position function closeMenu() { isMenuOpen = false; } function toggleMenu() { if (isMenuOpen == true) closeMenu(); else openMenu(); } // Menu buttons // ============================================================================= function settingsMenuButton() { closeMenu(); closeOpenDialogs(); openSettings(); } function chatMenuButton() { closeMenu(); closeOpenDialogs(); openChat(); } function diplomacyMenuButton() { closeMenu(); closeOpenDialogs(); openDiplomacy(); } function pauseMenuButton() { togglePause(); } function resignMenuButton() { closeMenu(); closeOpenDialogs(); pauseGame(); var btCaptions = ["Yes", "No"]; var btCode = [resignGame, resumeGame]; messageBox(400, 200, "Are you sure you want to resign?", "Confirmation", 0, btCaptions, btCode); } function exitMenuButton() { closeMenu(); closeOpenDialogs(); pauseGame(); var btCaptions = ["Yes", "No"]; var btCode = [leaveGame, resumeGame]; messageBox(400, 200, "Are you sure you want to quit?", "Confirmation", 0, btCaptions, btCode); } + function openDeleteDialog(selection) { closeMenu(); closeOpenDialogs(); - var deleteSelectedEntities = function () + var deleteSelectedEntities = function (selectionArg) { - Engine.PostNetworkCommand({"type": "delete-entities", "entities": selection}); + Engine.PostNetworkCommand({"type": "delete-entities", "entities": selectionArg}); }; var btCaptions = ["Yes", "No"]; var btCode = [deleteSelectedEntities, resumeGame]; - messageBox(400, 200, "Destroy everything currently selected?", "Delete", 0, btCaptions, btCode); + messageBox(400, 200, "Destroy everything currently selected?", "Delete", 0, btCaptions, btCode, [selection, null]); } // Menu functions // ============================================================================= function openSave() { closeMenu(); closeOpenDialogs(); pauseGame(); - Engine.PushGuiPage("page_savegame.xml", {"gameDataCallback": getSavedGameData, "closeCallback": resumeGame}); + var savedGameData = getSavedGameData(); + Engine.PushGuiPage("page_savegame.xml", {"savedGameData": savedGameData, "callback": "resumeGame"}); } function openSettings() { - getGUIObjectByName("settingsDialogPanel").hidden = false; + Engine.GetGUIObjectByName("settingsDialogPanel").hidden = false; pauseGame(); } function closeSettings(resume) { - getGUIObjectByName("settingsDialogPanel").hidden = true; + Engine.GetGUIObjectByName("settingsDialogPanel").hidden = true; if (resume) resumeGame(); } function openChat() { - getGUIObjectByName("chatInput").focus(); // Grant focus to the input area - getGUIObjectByName("chatDialogPanel").hidden = false; + Engine.GetGUIObjectByName("chatInput").focus(); // Grant focus to the input area + Engine.GetGUIObjectByName("chatDialogPanel").hidden = false; } function closeChat() { - getGUIObjectByName("chatInput").caption = ""; // Clear chat input - getGUIObjectByName("chatInput").blur(); // Remove focus - getGUIObjectByName("chatDialogPanel").hidden = true; + Engine.GetGUIObjectByName("chatInput").caption = ""; // Clear chat input + Engine.GetGUIObjectByName("chatInput").blur(); // Remove focus + Engine.GetGUIObjectByName("chatDialogPanel").hidden = true; } function toggleChatWindow(teamChat) { closeSettings(); - var chatWindow = getGUIObjectByName("chatDialogPanel"); - var chatInput = getGUIObjectByName("chatInput"); + var chatWindow = Engine.GetGUIObjectByName("chatDialogPanel"); + var chatInput = Engine.GetGUIObjectByName("chatInput"); if (chatWindow.hidden) chatInput.focus(); // Grant focus to the input area else { if (chatInput.caption.length) { submitChatInput(); return; } chatInput.caption = ""; // Clear chat input } - getGUIObjectByName("toggleTeamChat").checked = teamChat; + Engine.GetGUIObjectByName("toggleTeamChat").checked = teamChat; chatWindow.hidden = !chatWindow.hidden; } function setDiplomacy(data) { Engine.PostNetworkCommand({"type": "diplomacy", "to": data.to, "player": data.player}); } function tributeResource(data) { Engine.PostNetworkCommand({"type": "tribute", "player": data.player, "amounts": data.amounts}); } function openDiplomacy() { if (isTradeOpen) closeTrade(); isDiplomacyOpen = true; var we = Engine.GetPlayerID(); var players = getPlayerData(g_PlayerAssignments); // Get offset for one line - var onesize = getGUIObjectByName("diplomacyPlayer[0]").size; + var onesize = Engine.GetGUIObjectByName("diplomacyPlayer[0]").size; var rowsize = onesize.bottom - onesize.top; // We don't include gaia for (var i = 1; i < players.length; i++) { // Apply offset - var row = getGUIObjectByName("diplomacyPlayer["+(i-1)+"]"); + var row = Engine.GetGUIObjectByName("diplomacyPlayer["+(i-1)+"]"); var size = row.size; size.top = rowsize*(i-1); size.bottom = rowsize*i; row.size = size; // Set background colour var playerColor = players[i].color.r+" "+players[i].color.g+" "+players[i].color.b; row.sprite = "colour: "+playerColor + " 32"; - getGUIObjectByName("diplomacyPlayerName["+(i-1)+"]").caption = "[color=\"" + playerColor + "\"]" + players[i].name + "[/color]"; - getGUIObjectByName("diplomacyPlayerCiv["+(i-1)+"]").caption = g_CivData[players[i].civ].Name; + Engine.GetGUIObjectByName("diplomacyPlayerName["+(i-1)+"]").caption = "[color=\"" + playerColor + "\"]" + players[i].name + "[/color]"; + Engine.GetGUIObjectByName("diplomacyPlayerCiv["+(i-1)+"]").caption = g_CivData[players[i].civ].Name; - getGUIObjectByName("diplomacyPlayerTeam["+(i-1)+"]").caption = (players[i].team < 0) ? "None" : players[i].team+1; + Engine.GetGUIObjectByName("diplomacyPlayerTeam["+(i-1)+"]").caption = (players[i].team < 0) ? "None" : players[i].team+1; if (i != we) - getGUIObjectByName("diplomacyPlayerTheirs["+(i-1)+"]").caption = (players[i].isAlly[we] ? "Ally" : (players[i].isNeutral[we] ? "Neutral" : "Enemy")); + Engine.GetGUIObjectByName("diplomacyPlayerTheirs["+(i-1)+"]").caption = (players[i].isAlly[we] ? "Ally" : (players[i].isNeutral[we] ? "Neutral" : "Enemy")); // Don't display the options for ourself, or if we or the other player aren't active anymore if (i == we || players[we].state != "active" || players[i].state != "active") { // Hide the unused/unselectable options for each (var a in ["TributeFood", "TributeWood", "TributeStone", "TributeMetal", "Ally", "Neutral", "Enemy"]) - getGUIObjectByName("diplomacyPlayer"+a+"["+(i-1)+"]").hidden = true; + Engine.GetGUIObjectByName("diplomacyPlayer"+a+"["+(i-1)+"]").hidden = true; continue; } // Tribute for each (var resource in ["food", "wood", "stone", "metal"]) { - var button = getGUIObjectByName("diplomacyPlayerTribute"+toTitleCase(resource)+"["+(i-1)+"]"); + var button = Engine.GetGUIObjectByName("diplomacyPlayerTribute"+toTitleCase(resource)+"["+(i-1)+"]"); button.onpress = (function(player, resource, button){ // Implement something like how unit batch training works. Shift+click to send 500, shift+click+click to send 1000, etc. // Also see input.js (searching for "INPUT_MASSTRIBUTING" should get all the relevant parts). var multiplier = 1; return function() { var isBatchTrainPressed = Engine.HotkeyIsPressed("session.masstribute"); if (isBatchTrainPressed) { inputState = INPUT_MASSTRIBUTING; multiplier += multiplier == 1 ? 4 : 5; } var amounts = { "food": (resource == "food" ? 100 : 0) * multiplier, "wood": (resource == "wood" ? 100 : 0) * multiplier, "stone": (resource == "stone" ? 100 : 0) * multiplier, "metal": (resource == "metal" ? 100 : 0) * multiplier, }; button.tooltip = formatTributeTooltip(players[player], resource, amounts[resource]); // This is in a closure so that we have access to `player`, `amounts`, and `multiplier` without some // evil global variable hackery. flushTributing = function() { tributeResource({"player": player, "amounts": amounts}); multiplier = 1; button.tooltip = formatTributeTooltip(players[player], resource, 100); }; if (!isBatchTrainPressed) flushTributing(); }; })(i, resource, button); button.hidden = false; button.tooltip = formatTributeTooltip(players[i], resource, 100); } // Skip our own teams on teams locked if (players[we].teamsLocked && players[we].team != -1 && players[we].team == players[i].team) continue; // Diplomacy settings // Set up the buttons for each (var setting in ["ally", "neutral", "enemy"]) { - var button = getGUIObjectByName("diplomacyPlayer"+toTitleCase(setting)+"["+(i-1)+"]"); + var button = Engine.GetGUIObjectByName("diplomacyPlayer"+toTitleCase(setting)+"["+(i-1)+"]"); if (setting == "ally") { if (players[we].isAlly[i]) button.caption = "x"; else button.caption = ""; } else if (setting == "neutral") { if (players[we].isNeutral[i]) button.caption = "x"; else button.caption = ""; } else // "enemy" { if (players[we].isEnemy[i]) button.caption = "x"; else button.caption = ""; } button.onpress = (function(e){ return function() { setDiplomacy(e) } })({"player": i, "to": setting}); button.hidden = false; } } - getGUIObjectByName("diplomacyDialogPanel").hidden = false; + Engine.GetGUIObjectByName("diplomacyDialogPanel").hidden = false; } function closeDiplomacy() { isDiplomacyOpen = false; - getGUIObjectByName("diplomacyDialogPanel").hidden = true; + Engine.GetGUIObjectByName("diplomacyDialogPanel").hidden = true; } function toggleDiplomacy() { if (isDiplomacyOpen) closeDiplomacy(); else openDiplomacy(); }; function openTrade() { if (isDiplomacyOpen) closeDiplomacy(); isTradeOpen = true; var updateButtons = function() { for (var res in button) { button[res].label.caption = proba[res] + "%"; if (res == selec) { button[res].res.enabled = false; button[res].sel.hidden = false; button[res].up.hidden = true; button[res].dn.hidden = true; } else { button[res].res.enabled = true; button[res].sel.hidden = true; button[res].up.hidden = (proba[res] == 100 || proba[selec] == 0); button[res].dn.hidden = (proba[res] == 0 || proba[selec] == 100); } } } var proba = Engine.GuiInterfaceCall("GetTradingGoods"); var button = {}; var selec = RESOURCES[0]; for (var i = 0; i < RESOURCES.length; ++i) { - var buttonResource = getGUIObjectByName("tradeResource["+i+"]"); + var buttonResource = Engine.GetGUIObjectByName("tradeResource["+i+"]"); if (i > 0) { - var size = getGUIObjectByName("tradeResource["+(i-1)+"]").size; + var size = Engine.GetGUIObjectByName("tradeResource["+(i-1)+"]").size; var width = size.right - size.left; size.left += width; size.right += width; - getGUIObjectByName("tradeResource["+i+"]").size = size; + Engine.GetGUIObjectByName("tradeResource["+i+"]").size = size; } var resource = RESOURCES[i]; proba[resource] = (proba[resource] ? proba[resource] : 0); - var buttonResource = getGUIObjectByName("tradeResourceButton["+i+"]"); - var icon = getGUIObjectByName("tradeResourceIcon["+i+"]"); + var buttonResource = Engine.GetGUIObjectByName("tradeResourceButton["+i+"]"); + var icon = Engine.GetGUIObjectByName("tradeResourceIcon["+i+"]"); icon.sprite = "stretched:session/icons/resources/" + resource + ".png"; - var label = getGUIObjectByName("tradeResourceText["+i+"]"); - var buttonUp = getGUIObjectByName("tradeArrowUp["+i+"]"); - var buttonDn = getGUIObjectByName("tradeArrowDn["+i+"]"); - var iconSel = getGUIObjectByName("tradeResourceSelection["+i+"]"); + var label = Engine.GetGUIObjectByName("tradeResourceText["+i+"]"); + var buttonUp = Engine.GetGUIObjectByName("tradeArrowUp["+i+"]"); + var buttonDn = Engine.GetGUIObjectByName("tradeArrowDn["+i+"]"); + var iconSel = Engine.GetGUIObjectByName("tradeResourceSelection["+i+"]"); button[resource] = { "res": buttonResource, "up": buttonUp, "dn": buttonDn, "label": label, "sel": iconSel }; buttonResource.onpress = (function(resource){ return function() { if (selec == resource) return; selec = resource; updateButtons(); } })(resource); buttonUp.onpress = (function(resource){ return function() { proba[resource] += Math.min(STEP, proba[selec]); proba[selec] -= Math.min(STEP, proba[selec]); Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba}); updateButtons(); } })(resource); buttonDn.onpress = (function(resource){ return function() { proba[selec] += Math.min(STEP, proba[resource]); proba[resource] -= Math.min(STEP, proba[resource]); Engine.PostNetworkCommand({"type": "set-trading-goods", "tradingGoods": proba}); updateButtons(); } })(resource); } updateButtons(); var traderNumber = Engine.GuiInterfaceCall("GetTraderNumber"); var caption = ""; var comma = ""; if (traderNumber.landTrader.total == 0) caption += "0"; else { if (traderNumber.landTrader.trading > 0) { caption += traderNumber.landTrader.trading + " trading" comma = ", "; } if (traderNumber.landTrader.garrisoned > 0) { caption += comma + traderNumber.landTrader.garrisoned + " garrisoned inside ships"; comma = ", "; } var inactive = traderNumber.landTrader.total - traderNumber.landTrader.trading - traderNumber.landTrader.garrisoned; if (inactive > 0) caption += comma + "[color=\"orange\"]" + inactive + " inactive[/color]"; } - getGUIObjectByName("landTraders").caption = caption; + Engine.GetGUIObjectByName("landTraders").caption = caption; caption = ""; comma = ""; if (traderNumber.shipTrader.total == 0) caption += "0"; else { if (traderNumber.shipTrader.trading > 0) { caption += traderNumber.shipTrader.trading + " trading" comma = ", "; } var inactive = traderNumber.shipTrader.total - traderNumber.shipTrader.trading; if (inactive > 0) caption += comma + "[color=\"orange\"]" + inactive + " inactive[/color]"; } - getGUIObjectByName("shipTraders").caption = caption; + Engine.GetGUIObjectByName("shipTraders").caption = caption; - getGUIObjectByName("tradeDialogPanel").hidden = false; + Engine.GetGUIObjectByName("tradeDialogPanel").hidden = false; } function closeTrade() { isTradeOpen = false; - getGUIObjectByName("tradeDialogPanel").hidden = true; + Engine.GetGUIObjectByName("tradeDialogPanel").hidden = true; } function toggleTrade() { if (isTradeOpen) closeTrade(); else openTrade(); }; function toggleGameSpeed() { - var gameSpeed = getGUIObjectByName("gameSpeed"); + var gameSpeed = Engine.GetGUIObjectByName("gameSpeed"); gameSpeed.hidden = !gameSpeed.hidden; } /** * Pause the game in single player mode. */ function pauseGame() { if (g_IsNetworked) return; - getGUIObjectByName("pauseButtonText").caption = RESUME; - getGUIObjectByName("pauseOverlay").hidden = false; - setPaused(true); + Engine.GetGUIObjectByName("pauseButtonText").caption = RESUME; + Engine.GetGUIObjectByName("pauseOverlay").hidden = false; + Engine.SetPaused(true); } function resumeGame() { - getGUIObjectByName("pauseButtonText").caption = PAUSE; - getGUIObjectByName("pauseOverlay").hidden = true; - setPaused(false); + Engine.GetGUIObjectByName("pauseButtonText").caption = PAUSE; + Engine.GetGUIObjectByName("pauseOverlay").hidden = true; + Engine.SetPaused(false); } function togglePause() { closeMenu(); closeOpenDialogs(); - var pauseOverlay = getGUIObjectByName("pauseOverlay"); + var pauseOverlay = Engine.GetGUIObjectByName("pauseOverlay"); if (pauseOverlay.hidden) { - getGUIObjectByName("pauseButtonText").caption = RESUME; - setPaused(true); + Engine.GetGUIObjectByName("pauseButtonText").caption = RESUME; + Engine.SetPaused(true); } else { - setPaused(false); - getGUIObjectByName("pauseButtonText").caption = PAUSE; + Engine.SetPaused(false); + Engine.GetGUIObjectByName("pauseButtonText").caption = PAUSE; } pauseOverlay.hidden = !pauseOverlay.hidden; } function openManual() { closeMenu(); closeOpenDialogs(); pauseGame(); Engine.PushGuiPage("page_manual.xml", {"page": "intro", "closeCallback": resumeGame}); } function toggleDeveloperOverlay() { if (Engine.HasXmppClient() && Engine.IsRankedGame()) return; - var devCommands = getGUIObjectByName("devCommands"); + var devCommands = Engine.GetGUIObjectByName("devCommands"); var text = devCommands.hidden ? "opened." : "closed."; submitChatDirectly("The Developer Overlay was " + text); // Update the options dialog - getGUIObjectByName("developerOverlayCheckbox").checked = devCommands.hidden; + Engine.GetGUIObjectByName("developerOverlayCheckbox").checked = devCommands.hidden; devCommands.hidden = !devCommands.hidden; } function closeOpenDialogs() { closeMenu(); closeChat(); closeDiplomacy(); closeTrade(); closeSettings(false); } function formatTributeTooltip(player, resource, amount) { var playerColor = player.color.r + " " + player.color.g + " " + player.color.b; return "Tribute " + amount + " " + resource + " to [color=\"" + playerColor + "\"]" + player.name + "[/color]. Shift-click to tribute " + (amount < 500 ? 500 : amount + 500) + "."; } Index: ps/trunk/binaries/data/mods/public/gui/session/selection_details.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/selection_details.js (revision 14495) +++ ps/trunk/binaries/data/mods/public/gui/session/selection_details.js (revision 14496) @@ -1,347 +1,347 @@ function layoutSelectionSingle() { - getGUIObjectByName("detailsAreaSingle").hidden = false; - getGUIObjectByName("detailsAreaMultiple").hidden = true; + Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false; + Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = true; } function layoutSelectionMultiple() { - getGUIObjectByName("detailsAreaMultiple").hidden = false; - getGUIObjectByName("detailsAreaSingle").hidden = true; + Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = false; + Engine.GetGUIObjectByName("detailsAreaSingle").hidden = true; } // Fills out information that most entities have function displaySingle(entState, template) { // Get general unit and player data var specificName = template.name.specific; var genericName = template.name.generic != template.name.specific? template.name.generic : ""; // If packed, add that to the generic name (reduces template clutter) if (genericName && template.pack && template.pack.state == "packed") genericName += " -- Packed"; var playerState = g_Players[entState.player]; var civName = g_CivData[playerState.civ].Name; var civEmblem = g_CivData[playerState.civ].Emblem; var playerName = playerState.name; var playerColor = playerState.color.r + " " + playerState.color.g + " " + playerState.color.b + " 128"; // Indicate disconnected players by prefixing their name if (g_Players[entState.player].offline) { playerName = "[OFFLINE] " + playerName; } // Rank if (entState.identity && entState.identity.rank && entState.identity.classes) { - getGUIObjectByName("rankIcon").tooltip = entState.identity.rank + " Rank"; - getGUIObjectByName("rankIcon").sprite = getRankIconSprite(entState); - getGUIObjectByName("rankIcon").hidden = false; + Engine.GetGUIObjectByName("rankIcon").tooltip = entState.identity.rank + " Rank"; + Engine.GetGUIObjectByName("rankIcon").sprite = getRankIconSprite(entState); + Engine.GetGUIObjectByName("rankIcon").hidden = false; } else { - getGUIObjectByName("rankIcon").hidden = true; - getGUIObjectByName("rankIcon").tooltip = ""; + Engine.GetGUIObjectByName("rankIcon").hidden = true; + Engine.GetGUIObjectByName("rankIcon").tooltip = ""; } // Hitpoints if (entState.hitpoints) { - var unitHealthBar = getGUIObjectByName("healthBar"); + var unitHealthBar = Engine.GetGUIObjectByName("healthBar"); var healthSize = unitHealthBar.size; healthSize.rright = 100*Math.max(0, Math.min(1, entState.hitpoints / entState.maxHitpoints)); unitHealthBar.size = healthSize; var hitpoints = Math.ceil(entState.hitpoints) + " / " + entState.maxHitpoints; - getGUIObjectByName("healthStats").caption = hitpoints; - getGUIObjectByName("healthSection").hidden = false; + Engine.GetGUIObjectByName("healthStats").caption = hitpoints; + Engine.GetGUIObjectByName("healthSection").hidden = false; } else { - getGUIObjectByName("healthSection").hidden = true; + Engine.GetGUIObjectByName("healthSection").hidden = true; } // TODO: Stamina var player = Engine.GetPlayerID(); if (entState.stamina && (entState.player == player || g_DevSettings.controlAll)) { - getGUIObjectByName("staminaSection").hidden = false; + Engine.GetGUIObjectByName("staminaSection").hidden = false; } else { - getGUIObjectByName("staminaSection").hidden = true; + Engine.GetGUIObjectByName("staminaSection").hidden = true; } // Experience if (entState.promotion) { - var experienceBar = getGUIObjectByName("experienceBar"); + var experienceBar = Engine.GetGUIObjectByName("experienceBar"); var experienceSize = experienceBar.size; experienceSize.rtop = 100 - (100 * Math.max(0, Math.min(1, 1.0 * +entState.promotion.curr / +entState.promotion.req))); experienceBar.size = experienceSize; var experience = "[font=\"serif-bold-13\"]Experience: [/font]" + Math.floor(entState.promotion.curr); if (entState.promotion.curr < entState.promotion.req) experience += " / " + entState.promotion.req; - getGUIObjectByName("experience").tooltip = experience; - getGUIObjectByName("experience").hidden = false; + Engine.GetGUIObjectByName("experience").tooltip = experience; + Engine.GetGUIObjectByName("experience").hidden = false; } else { - getGUIObjectByName("experience").hidden = true; + Engine.GetGUIObjectByName("experience").hidden = true; } // Resource stats if (entState.resourceSupply) { var resources = entState.resourceSupply.isInfinite ? "\u221E" : // Infinity symbol Math.ceil(+entState.resourceSupply.amount) + " / " + entState.resourceSupply.max; var resourceType = entState.resourceSupply.type["generic"]; if (resourceType == "treasure") resourceType = entState.resourceSupply.type["specific"]; - var unitResourceBar = getGUIObjectByName("resourceBar"); + var unitResourceBar = Engine.GetGUIObjectByName("resourceBar"); var resourceSize = unitResourceBar.size; resourceSize.rright = entState.resourceSupply.isInfinite ? 100 : 100 * Math.max(0, Math.min(1, +entState.resourceSupply.amount / +entState.resourceSupply.max)); unitResourceBar.size = resourceSize; - getGUIObjectByName("resourceLabel").caption = toTitleCase(resourceType) + ":"; - getGUIObjectByName("resourceStats").caption = resources; + Engine.GetGUIObjectByName("resourceLabel").caption = toTitleCase(resourceType) + ":"; + Engine.GetGUIObjectByName("resourceStats").caption = resources; if (entState.hitpoints) - getGUIObjectByName("resourceSection").size = getGUIObjectByName("staminaSection").size; + Engine.GetGUIObjectByName("resourceSection").size = Engine.GetGUIObjectByName("staminaSection").size; else - getGUIObjectByName("resourceSection").size = getGUIObjectByName("healthSection").size; + Engine.GetGUIObjectByName("resourceSection").size = Engine.GetGUIObjectByName("healthSection").size; - getGUIObjectByName("resourceSection").hidden = false; + Engine.GetGUIObjectByName("resourceSection").hidden = false; } else { - getGUIObjectByName("resourceSection").hidden = true; + Engine.GetGUIObjectByName("resourceSection").hidden = true; } // Resource carrying if (entState.resourceCarrying && entState.resourceCarrying.length) { // We should only be carrying one resource type at once, so just display the first var carried = entState.resourceCarrying[0]; - getGUIObjectByName("resourceCarryingIcon").hidden = false; - getGUIObjectByName("resourceCarryingText").hidden = false; - getGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/"+carried.type+".png"; - getGUIObjectByName("resourceCarryingText").caption = carried.amount + " / " + carried.max; - getGUIObjectByName("resourceCarryingIcon").tooltip = ""; + Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; + Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; + Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/"+carried.type+".png"; + Engine.GetGUIObjectByName("resourceCarryingText").caption = carried.amount + " / " + carried.max; + Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = ""; } // Use the same indicators for traders else if (entState.trader && entState.trader.goods.amount) { - getGUIObjectByName("resourceCarryingIcon").hidden = false; - getGUIObjectByName("resourceCarryingText").hidden = false; - getGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/"+entState.trader.goods.type+".png"; + Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; + Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; + Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/resources/"+entState.trader.goods.type+".png"; var totalGain = entState.trader.goods.amount.traderGain; if (entState.trader.goods.amount.market1Gain) totalGain += entState.trader.goods.amount.market1Gain; if (entState.trader.goods.amount.market2Gain) totalGain += entState.trader.goods.amount.market2Gain; - getGUIObjectByName("resourceCarryingText").caption = totalGain; - getGUIObjectByName("resourceCarryingIcon").tooltip = "Gain: " + getTradingTooltip(entState.trader.goods.amount); + Engine.GetGUIObjectByName("resourceCarryingText").caption = totalGain; + Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = "Gain: " + getTradingTooltip(entState.trader.goods.amount); } // And for number of workers else if (entState.foundation) { - getGUIObjectByName("resourceCarryingIcon").hidden = false; - getGUIObjectByName("resourceCarryingText").hidden = false; - getGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; - getGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " "; - getGUIObjectByName("resourceCarryingIcon").tooltip = "Number of builders"; + Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; + Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; + Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; + Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.foundation.numBuilders + " "; + Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = "Number of builders"; } else if (entState.resourceSupply && (!entState.resourceSupply.killBeforeGather || !entState.hitpoints)) { - getGUIObjectByName("resourceCarryingIcon").hidden = false; - getGUIObjectByName("resourceCarryingText").hidden = false; - getGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; - getGUIObjectByName("resourceCarryingText").caption = entState.resourceSupply.gatherers.length + " / " + entState.resourceSupply.maxGatherers + " "; - getGUIObjectByName("resourceCarryingIcon").tooltip = "Current/max gatherers"; + Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = false; + Engine.GetGUIObjectByName("resourceCarryingText").hidden = false; + Engine.GetGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/repair.png"; + Engine.GetGUIObjectByName("resourceCarryingText").caption = entState.resourceSupply.gatherers.length + " / " + entState.resourceSupply.maxGatherers + " "; + Engine.GetGUIObjectByName("resourceCarryingIcon").tooltip = "Current/max gatherers"; } else { - getGUIObjectByName("resourceCarryingIcon").hidden = true; - getGUIObjectByName("resourceCarryingText").hidden = true; + Engine.GetGUIObjectByName("resourceCarryingIcon").hidden = true; + Engine.GetGUIObjectByName("resourceCarryingText").hidden = true; } // Set Player details - getGUIObjectByName("specific").caption = specificName; - getGUIObjectByName("player").caption = playerName; - getGUIObjectByName("playerColorBackground").sprite = "colour: " + playerColor; + Engine.GetGUIObjectByName("specific").caption = specificName; + Engine.GetGUIObjectByName("player").caption = playerName; + Engine.GetGUIObjectByName("playerColorBackground").sprite = "colour: " + playerColor; if (genericName) { - getGUIObjectByName("generic").caption = "(" + genericName + ")"; + Engine.GetGUIObjectByName("generic").caption = "(" + genericName + ")"; } else { - getGUIObjectByName("generic").caption = ""; + Engine.GetGUIObjectByName("generic").caption = ""; } if ("Gaia" != civName) { - getGUIObjectByName("playerCivIcon").sprite = "stretched:grayscale:" + civEmblem; - getGUIObjectByName("player").tooltip = civName; + Engine.GetGUIObjectByName("playerCivIcon").sprite = "stretched:grayscale:" + civEmblem; + Engine.GetGUIObjectByName("player").tooltip = civName; } else { - getGUIObjectByName("playerCivIcon").sprite = ""; - getGUIObjectByName("player").tooltip = ""; + Engine.GetGUIObjectByName("playerCivIcon").sprite = ""; + Engine.GetGUIObjectByName("player").tooltip = ""; } // Icon image if (template.icon) { - getGUIObjectByName("icon").sprite = "stretched:session/portraits/" + template.icon; + Engine.GetGUIObjectByName("icon").sprite = "stretched:session/portraits/" + template.icon; } else { // TODO: we should require all entities to have icons, so this case never occurs - getGUIObjectByName("icon").sprite = "bkFillBlack"; + Engine.GetGUIObjectByName("icon").sprite = "bkFillBlack"; } // Attack and Armor var type = ""; var attack = "[font=\"serif-bold-13\"]"+type+"Attack:[/font] " + damageTypeDetails(entState.attack); if (entState.attack) { type = entState.attack.type + " "; // Show max attack range if ranged attack, also convert to tiles (4m per tile) if (entState.attack.type == "Ranged") { var realRange = entState.attack.elevationAdaptedRange; var range = entState.attack.maxRange; attack += ", [font=\"serif-bold-13\"]Range:[/font] " + Math.round(range/4); if (Math.round((realRange - range)/4) > 0) { attack += " (+" + Math.round((realRange - range)/4) + ")"; } else if (Math.round((realRange - range)/4) < 0) { attack += " (" + Math.round((realRange - range)/4) + ")"; } // don't show when it's 0 } } - getGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + armorTypeDetails(entState.armour); + Engine.GetGUIObjectByName("attackAndArmorStats").tooltip = attack + "\n[font=\"serif-bold-13\"]Armor:[/font] " + armorTypeDetails(entState.armour); // Icon Tooltip var iconTooltip = ""; if (genericName) iconTooltip = "[font=\"serif-bold-16\"]" + genericName + "[/font]"; if (template.tooltip) iconTooltip += "\n[font=\"serif-13\"]" + template.tooltip + "[/font]"; - getGUIObjectByName("iconBorder").tooltip = iconTooltip; + Engine.GetGUIObjectByName("iconBorder").tooltip = iconTooltip; // Unhide Details Area - getGUIObjectByName("detailsAreaSingle").hidden = false; - getGUIObjectByName("detailsAreaMultiple").hidden = true; + Engine.GetGUIObjectByName("detailsAreaSingle").hidden = false; + Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = true; } // Fills out information for multiple entities function displayMultiple(selection, template) { var averageHealth = 0; var maxHealth = 0; for (var i = 0; i < selection.length; i++) { var entState = GetEntityState(selection[i]) if (entState) { if (entState.hitpoints) { averageHealth += entState.hitpoints; maxHealth += entState.maxHitpoints; } } } if (averageHealth > 0) { - var unitHealthBar = getGUIObjectByName("healthBarMultiple"); + var unitHealthBar = Engine.GetGUIObjectByName("healthBarMultiple"); var healthSize = unitHealthBar.size; healthSize.rtop = 100-100*Math.max(0, Math.min(1, averageHealth / maxHealth)); unitHealthBar.size = healthSize; var hitpoints = "[font=\"serif-bold-13\"]Hitpoints [/font]" + averageHealth + " / " + maxHealth; - var healthMultiple = getGUIObjectByName("healthMultiple"); + var healthMultiple = Engine.GetGUIObjectByName("healthMultiple"); healthMultiple.tooltip = hitpoints; healthMultiple.hidden = false; } else { - getGUIObjectByName("healthMultiple").hidden = true; + Engine.GetGUIObjectByName("healthMultiple").hidden = true; } // TODO: Stamina - // getGUIObjectByName("staminaBarMultiple"); + // Engine.GetGUIObjectByName("staminaBarMultiple"); - getGUIObjectByName("numberOfUnits").caption = selection.length; + Engine.GetGUIObjectByName("numberOfUnits").caption = selection.length; // Unhide Details Area - getGUIObjectByName("detailsAreaMultiple").hidden = false; - getGUIObjectByName("detailsAreaSingle").hidden = true; + Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = false; + Engine.GetGUIObjectByName("detailsAreaSingle").hidden = true; } // Updates middle entity Selection Details Panel function updateSelectionDetails() { - var supplementalDetailsPanel = getGUIObjectByName("supplementalSelectionDetails"); - var detailsPanel = getGUIObjectByName("selectionDetails"); - var commandsPanel = getGUIObjectByName("unitCommands"); + var supplementalDetailsPanel = Engine.GetGUIObjectByName("supplementalSelectionDetails"); + var detailsPanel = Engine.GetGUIObjectByName("selectionDetails"); + var commandsPanel = Engine.GetGUIObjectByName("unitCommands"); g_Selection.update(); var selection = g_Selection.toList(); if (selection.length == 0) { - getGUIObjectByName("detailsAreaMultiple").hidden = true; - getGUIObjectByName("detailsAreaSingle").hidden = true; + Engine.GetGUIObjectByName("detailsAreaMultiple").hidden = true; + Engine.GetGUIObjectByName("detailsAreaSingle").hidden = true; hideUnitCommands(); supplementalDetailsPanel.hidden = true; detailsPanel.hidden = true; commandsPanel.hidden = true; return; } /* If the unit has no data (e.g. it was killed), don't try displaying any data for it. (TODO: it should probably be removed from the selection too; also need to handle multi-unit selections) */ var entState = GetExtendedEntityState(selection[0]); if (!entState) return; var template = GetTemplateData(entState.template); // Fill out general info and display it if (selection.length == 1) displaySingle(entState, template); else displayMultiple(selection, template); // Show Panels supplementalDetailsPanel.hidden = false; detailsPanel.hidden = false; commandsPanel.hidden = false; // Fill out commands panel for specific unit selected (or first unit of primary group) updateUnitCommands(entState, supplementalDetailsPanel, commandsPanel, selection); } Index: ps/trunk/binaries/data/mods/public/gui/session/session.xml =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/session.xml (revision 14495) +++ ps/trunk/binaries/data/mods/public/gui/session/session.xml (revision 14496) @@ -1,1333 +1,1333 @@ Engine.PopGuiPage();