Skip to content
Snippets Groups Projects
Commit 618430b7 authored by DarkGod's avatar DarkGod
Browse files

swtich to cef3 instead of awesomium. requires branch 1547

parent 3142479f
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ if __SELFEXE then
fs.mount(dir..fs.getPathSeparator().."game"..fs.getPathSeparator().."thirdparty", "/", true)
fs.mount(dir..fs.getPathSeparator().."game", "/", true)
else
print("No SelfExe, using basic path")
fs.mount("game"..fs.getPathSeparator().."thirdparty", "/", true)
fs.mount("game", "/", true)
end
......
......@@ -36,6 +36,10 @@ newoption {
newoption {
trigger = "relpath",
description = "Links libraries relative to the application path for redistribution",
allowed = {
{ "32", "32 bits location" },
{ "64", "64 bits location" },
}
}
newoption {
trigger = "luaassert",
......@@ -66,6 +70,11 @@ newoption {
description = "Use awesomium embedded browser as the webcore"
}
newoption {
trigger = "web-cef3",
description = "Use CEF3 embedded browser as the webcore"
}
newoption {
trigger = "wincross",
description = "Enables cross-compilation for windows (from linux)"
......
......@@ -42,6 +42,12 @@ project "TEngine"
defines { [[TENGINE_HOME_PATH='".t-engine"']], "TE4CORE_VERSION="..TE4CORE_VERSION }
buildoptions { "-O3" }
if _OPTIONS.relpath=="32" then linkoptions{"-Wl,-rpath -Wl,\\\$\$ORIGIN/lib "} end
if _OPTIONS.relpath=="64" then linkoptions{"-Wl,-rpath -Wl,\\\$\$ORIGIN/lib64 "} end
if _OPTIONS.relpath == "32" then defines{"TE4_RELPATH32"} end
if _OPTIONS.relpath == "64" then defines{"TE4_RELPATH64"} end
links { "m" }
if _OPTIONS.no_rwops_size then defines{"NO_RWOPS_SIZE"} end
......@@ -525,6 +531,30 @@ project "te4-web"
files { "../src/web-awesomium/*.cpp", }
end
if _OPTIONS['web-cef3'] and not _OPTIONS.wincross then
project "te4-web"
kind "SharedLib"
language "C++"
targetname "te4-web"
if _OPTIONS.relpath=="32" then linkoptions{"-Wl,-rpath -Wl,\\\$\$ORIGIN "} end
if _OPTIONS.relpath=="64" then linkoptions{"-Wl,-rpath -Wl,\\\$\$ORIGIN "} end
buildoptions{"-Wall -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm"}
libdirs {"/opt/cef3/1547/out/Release/obj.target/", "/opt/cef3/1547/Release/"}
includedirs {"/opt/cef3/1547/include/", "/opt/cef3/1547/"}
links { "cef", "cef_dll_wrapper" }
files { "../src/web-cef3/*.cpp", }
configuration "macosx"
defines { 'SELFEXE_MACOSX' }
configuration "windows"
defines { 'SELFEXE_WINDOWS' }
configuration "linux"
defines { 'SELFEXE_LINUX' }
end
if _OPTIONS.steam then
dofile("../steamworks/build/steam-code.lua")
end
......@@ -132,10 +132,15 @@ function _M:generate()
elseif core.webview.kind == "cef3" then
function self.key.receiveKey(_, sym, ctrl, shift, alt, meta, unicode, isup, key, ismouse, keysym)
if not self.view then return end
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", isup, keysym)
if unicode then
keysym = unicode:sub(1):byte()
print("==uni", keysym, unicode)
self.view:injectKey(true, keysym, 0, unicode)
return
end
self.view:injectKey(isup, keysym)
print("==not", keysym)
self.view:injectKey(isup, keysym, 0, "")
end
end
end
......
......@@ -57,7 +57,8 @@ function _M:init()
l[#l+1] = {name="Credits", fct=function() game:registerDialog(require("mod.dialogs.Credits").new()) end}
l[#l+1] = {name="Exit", fct=function() game:onQuit() end}
if config.settings.cheat then l[#l+1] = {name="Reboot", fct=function() util.showMainMenu() end} end
if config.settings.cheat then l[#l+1] = {name="webtest", fct=function() util.browserOpenUrl("asset://te4/html/test.html") end} end
if config.settings.cheat then l[#l+1] = {name="webtest", fct=function() util.browserOpenUrl("http://google.com/") end} end
-- if config.settings.cheat then l[#l+1] = {name="webtest", fct=function() util.browserOpenUrl("asset://te4/html/test.html") end} end
self.c_background = Button.new{text=game.stopped and "Enable background" or "Disable background", fct=function() self:switchBackground() end}
self.c_version = Textzone.new{auto_width=true, auto_height=true, text=("#{bold}##B9E100#T-Engine4 version: %d.%d.%d"):format(engine.version[1], engine.version[2], engine.version[3])}
......
......@@ -5,7 +5,6 @@ solution "TEngine"
objdir "obj"
defines {"GLEW_STATIC"}
if _OPTIONS.force32bits then buildoptions{"-m32"} linkoptions{"-m32"} libdirs{"/usr/lib32"} end
if _OPTIONS.relpath then linkoptions{"-Wl,-rpath -Wl,\\\$\$ORIGIN/lib "} end
includedirs {
"src",
......@@ -21,6 +20,9 @@ solution "TEngine"
if _OPTIONS['web-awesomium'] then
includedirs { "src/web-awesomium" }
end
if _OPTIONS['web-cef3'] then
includedirs { "src/web-cef3" }
end
if _OPTIONS.wincross then
includedirs {
"/usr/i686-pc-mingw32/usr/include/",
......
......@@ -364,7 +364,10 @@ void on_event(SDL_Event *event)
else
lua_pushnil(L);
docall(L, 9, 0);
lua_pushnil(L);
lua_pushnumber(L, event->key.keysym.sym);
docall(L, 11, 0);
}
break;
case SDL_MOUSEBUTTONDOWN:
......@@ -1026,7 +1029,6 @@ void boot_lua(int state, bool rebooting, int argc, char *argv[])
luaopen_zlib(L);
luaopen_bit(L);
luaopen_wait(L);
if (te4_web_init) te4_web_init(L);
#ifdef STEAM_TE4
if (!no_steam) te4_steam_lua_init(L);
#endif
......@@ -1071,6 +1073,8 @@ void boot_lua(int state, bool rebooting, int argc, char *argv[])
PHYSFS_mount("game/", "/", 1);
}
if (te4_web_init) te4_web_init(L);
// And run the lua engine pre init scripts
if (!luaL_loadfile(L, "/loader/pre-init.lua"))
docall(L, 0, 0);
......@@ -1231,6 +1235,8 @@ int main(int argc, char *argv[])
if (!strncmp(arg, "--no-steam", 10)) no_steam = TRUE;
}
te4_web_load();
// Initialize display lock for thread safety.
renderingLock = SDL_CreateMutex();
realtimeLock = SDL_CreateMutex();
......@@ -1245,8 +1251,6 @@ int main(int argc, char *argv[])
init_openal();
te4_web_load();
// RNG init
init_gen_rand(time(NULL));
......
/*
TE4 - T-Engine 4
Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
No permission to copy or replicate in any ways.
*/
#ifndef __TE4WEB_INTERNAL_H__
#define __TE4WEB_INTERNAL_H__
#ifndef UINT_MAX
#define UINT_MAX 65535
#endif
#include <cef_app.h>
#include <cef_client.h>
#include <cef_display_handler.h>
#include <cef_render_handler.h>
#include <cef_request_handler.h>
#include <cef_download_handler.h>
#include <cef_render_process_handler.h>
#include <cef_v8.h>
extern void te4_web_init_utils();
extern void push_order(WebEvent *event);
extern WebEvent *pop_order();
extern void push_event(WebEvent *event);
extern WebEvent *pop_event();
extern void *(*web_mutex_create)();
extern void (*web_mutex_destroy)(void *mutex);
extern void (*web_mutex_lock)(void *mutex);
extern void (*web_mutex_unlock)(void *mutex);
#endif
/*
TE4 - T-Engine 4
Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
No permission to copy or replicate in any ways, awesomium is not gpl so we cant link directly
*/
extern "C" {
#include "tSDL.h"
#include "tgl.h"
#include "web-external.h"
}
#include "web.h"
#include "web-internal.h"
#include <cef_app.h>
#include <cef_app.h>
#include <cef_client.h>
#include <cef_display_handler.h>
#include <cef_render_handler.h>
#include <cef_request_handler.h>
#include <cef_render_process_handler.h>
#include <vector>
static std::vector<WebEvent*> *iqueue = new std::vector<WebEvent*>;
static std::vector<WebEvent*> *oqueue = new std::vector<WebEvent*>;
static void *lock_iqueue = NULL;
static void *lock_oqueue = NULL;
void te4_web_init_utils() {
if (!lock_iqueue) lock_iqueue = web_mutex_create();
if (!lock_oqueue) lock_oqueue = web_mutex_create();
}
void push_order(WebEvent *event)
{
if (!lock_iqueue) return;
web_mutex_lock(lock_iqueue);
iqueue->push_back(event);
web_mutex_unlock(lock_iqueue);
}
WebEvent *pop_order()
{
if (!lock_iqueue) return NULL;
WebEvent *event = NULL;
web_mutex_lock(lock_iqueue);
if (!iqueue->empty()) {
event = iqueue->back();
iqueue->pop_back();
}
web_mutex_unlock(lock_iqueue);
return event;
}
void push_event(WebEvent *event)
{
if (!lock_oqueue) return;
web_mutex_lock(lock_oqueue);
oqueue->push_back(event);
web_mutex_unlock(lock_oqueue);
}
WebEvent *pop_event()
{
if (!lock_oqueue) return NULL;
WebEvent *event = NULL;
web_mutex_lock(lock_oqueue);
if (!oqueue->empty()) {
event = oqueue->back();
oqueue->pop_back();
}
web_mutex_unlock(lock_oqueue);
return event;
}
This diff is collapsed.
/*
TE4 - T-Engine 4
Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini
No permission to copy or replicate in any ways.
*/
#ifndef __TE4WEB_H__
#define __TE4WEB_H__
#ifdef __cplusplus
/* C++ compiler needs to make this a C API. */
#if defined( _WIN32 )
/* Windows needs this to be a DLL, so be sure to export. */
#define WEB_TE4_API extern "C" __declspec( dllexport )
#else
/* Non-windows platforms are fine linking statically. */
#define WEB_TE4_API extern "C"
#endif
#else
/* C compiler is using this header. */
#define WEB_TE4_API
#endif
WEB_TE4_API void te4_web_setup(
int argc, char **argv, char *spawn,
void*(*mutex_create)(), void(*mutex_destroy)(void*), void(*mutex_lock)(void*), void(*mutex_unlock)(void*),
void*(*make_texture)(int, int), void (*del_texture)(void*), void (*texture_update)(void*, int, int, const void*),
void (*key_mods)(bool*, bool*, bool*, bool*),
void (*web_instant_js)(int handlers, const char *fct, int nb_args, WebJsValue *args, WebJsValue *ret)
);
WEB_TE4_API void te4_web_initialize(const char *locales, const char *pak);
WEB_TE4_API void te4_web_do_update(void (*cb)(WebEvent*));
WEB_TE4_API void te4_web_new(web_view_type *view, int w, int h);
WEB_TE4_API bool te4_web_close(web_view_type *view);
WEB_TE4_API void *te4_web_toscreen(web_view_type *view, int *w, int *h);
WEB_TE4_API bool te4_web_loading(web_view_type *view);
WEB_TE4_API void te4_web_focus(web_view_type *view, bool focus);
WEB_TE4_API void te4_web_inject_mouse_move(web_view_type *view, int x, int y);
WEB_TE4_API void te4_web_inject_mouse_wheel(web_view_type *view, int x, int y);
WEB_TE4_API void te4_web_inject_mouse_button(web_view_type *view, int kind, bool up);
WEB_TE4_API void te4_web_inject_key(web_view_type *view, int scancode, int asymb, const char *uni, int unilen, bool up);
WEB_TE4_API void te4_web_download_action(web_view_type *view, long id, const char *path);
WEB_TE4_API void te4_web_reply_local(int id, const char *mime, const char *result, size_t len);
WEB_TE4_API void te4_web_load_url(web_view_type *view, const char *url);
WEB_TE4_API void te4_web_set_js_call(web_view_type *view, const char *name);
#endif
......@@ -9,6 +9,10 @@
#define __TE4WEB_EXTERNAL_H__
enum web_event_kind {
// Internal stuff
TE4_WEB_EVENT_DELETE_TEXTURE,
// Eternal stuff
TE4_WEB_EVENT_TITLE_CHANGE,
TE4_WEB_EVENT_REQUEST_POPUP_URL,
TE4_WEB_EVENT_DOWNLOAD_REQUEST,
......@@ -53,6 +57,7 @@ typedef struct {
struct {
const char *code;
} run_lua;
void *texture;
} data;
} WebEvent;
......
......@@ -43,7 +43,7 @@ static void (*te4_web_setup)(
void (*)(bool*, bool*, bool*, bool*),
void (*)(int handlers, const char *fct, int nb_args, WebJsValue *args, WebJsValue *ret)
);
static void (*te4_web_initialize)();
static void (*te4_web_initialize)(const char *locales, const char *pak);
static void (*te4_web_do_update)(void (*cb)(WebEvent*));
static void (*te4_web_new)(web_view_type *view, int w, int h);
static bool (*te4_web_close)(web_view_type *view);
......@@ -180,7 +180,7 @@ static int lua_web_inject_key(lua_State *L) {
const char *uni = NULL;
size_t unilen = 0;
if (lua_isstring(L, 5)) uni = lua_tolstring(L, 5, &unilen);
printf("???=== %d\n", scancode);
te4_web_inject_key(view, scancode, asymb, uni, unilen, up);
return 0;
}
......@@ -372,12 +372,16 @@ void te4_web_update(lua_State *L) {
void te4_web_init(lua_State *L) {
if (!webcore) return;
te4_web_initialize();
char *locales = PHYSFS_getDependentPath("/cef3/locales/");
char *pak = PHYSFS_getDependentPath("/cef3/");
te4_web_initialize(locales, pak);
free(locales);
free(pak);
auxiliar_newclass(L, "web{view}", view_reg);
luaL_openlib(L, "core.webview", weblib, 0);
lua_pushstring(L, "kind");
lua_pushstring(L, "awesomium");
lua_pushstring(L, "cef3");
lua_settable(L, -3);
lua_settop(L, 0);
}
......@@ -469,10 +473,14 @@ static void web_instant_js(int handlers, const char *fct, int nb_args, WebJsValu
}
void te4_web_load() {
#if defined(SELFEXE_LINUX)
void *web = SDL_LoadObject("libte4-web.so");
#elif defined(SELFEXE_BSD)
#if defined(SELFEXE_LINUX) || defined(SELFEXE_BSD)
#if defined(TE4_RELPATH64)
void *web = SDL_LoadObject("lib64/libte4-web.so");
#elif defined(TE4_RELPATH64)
void *web = SDL_LoadObject("lib/libte4-web.so");
#else
void *web = SDL_LoadObject("libte4-web.so");
#endif
#elif defined(SELFEXE_WINDOWS)
void *web = SDL_LoadObject("te4-web.dll");
#elif defined(SELFEXE_MACOSX)
......@@ -491,7 +499,7 @@ void te4_web_load() {
void (*)(bool*, bool*, bool*, bool*),
void (*)(int handlers, const char *fct, int nb_args, WebJsValue *args, WebJsValue *ret)
)) SDL_LoadFunction(web, "te4_web_setup");
te4_web_initialize = (void (*)()) SDL_LoadFunction(web, "te4_web_initialize");
te4_web_initialize = (void (*)(const char *locales, const char *pak)) SDL_LoadFunction(web, "te4_web_initialize");
te4_web_do_update = (void (*)(void (*cb)(WebEvent*))) SDL_LoadFunction(web, "te4_web_do_update");
te4_web_new = (void (*)(web_view_type *view, int w, int h)) SDL_LoadFunction(web, "te4_web_new");
te4_web_close = (bool (*)(web_view_type *view)) SDL_LoadFunction(web, "te4_web_close");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment