mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 23:41:09 -04:00
Fix wrong link in hosting-webclient.md and simplify hosting-flask.md by combining the 3 html template files into 1
This commit is contained in:
parent
eb68cb9026
commit
35ed41ab81
@ -2,8 +2,6 @@ The website will be structured like so:
|
|||||||
|
|
||||||
```
|
```
|
||||||
websrv.py
|
websrv.py
|
||||||
templates/tmpl.html
|
|
||||||
templates/tmpl_lite.html
|
|
||||||
templates/play.html
|
templates/play.html
|
||||||
static/classisphere.js
|
static/classisphere.js
|
||||||
static/default.zip
|
static/default.zip
|
||||||
@ -39,54 +37,31 @@ if __name__ == "__main__":
|
|||||||
app.run()
|
app.run()
|
||||||
```
|
```
|
||||||
|
|
||||||
#### templates/tmpl.html
|
|
||||||
```HTML
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
|
||||||
<script src="/static/jquery.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="header">
|
|
||||||
<div class="row">
|
|
||||||
<a href="/"><h1 class="columns">Home</h1></a>
|
|
||||||
<a href="/play"><h1 class="columns">Play</h1></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="body">
|
|
||||||
{% block main %} {% endblock %}
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### templates/tmpl_lite.html
|
|
||||||
```HTML
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
<link href="/static/style.css" rel="stylesheet">
|
|
||||||
<script src="/static/jquery.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="body">
|
|
||||||
{% block main %} {% endblock %}
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
#### templates/play.html
|
#### templates/play.html
|
||||||
```HTML
|
```HTML
|
||||||
{% set mobile_mode = request.user_agent.platform in ('android', 'iphone', 'ipad') %}
|
{% set mobile_mode = request.user_agent.platform in ('android', 'iphone', 'ipad') %}
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<link href="/static/style.css" rel="stylesheet">
|
||||||
|
<script src="/static/jquery.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
{% if mobile_mode %}
|
{% if mobile_mode %}
|
||||||
{% extends 'tmpl_lite.html' %}
|
<style>
|
||||||
|
#body {min-height: 0px;}
|
||||||
|
.sec {padding: 0px;}
|
||||||
|
.row {padding: 0px;}
|
||||||
|
</style>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% extends 'tmpl.html' %}
|
<div id="header">
|
||||||
|
<div class="row">
|
||||||
|
<a href="/"><h1 class="columns">Home</h1></a>
|
||||||
|
<a href="/play"><h1 class="columns">Play</h1></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% block main %}
|
<div id="body">
|
||||||
<style>
|
<style>
|
||||||
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
|
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
|
||||||
#GameCanvas { display:block; box-sizing:border-box; border-width:0px !important; padding:0 !important; margin:0 auto; background-color: black; width:100%; height:auto; }
|
#GameCanvas { display:block; box-sizing:border-box; border-width:0px !important; padding:0 !important; margin:0 auto; background-color: black; width:100%; height:auto; }
|
||||||
@ -124,60 +99,53 @@ if __name__ == "__main__":
|
|||||||
if (canv_w % 2) { canv_w = canv_w - 1; }
|
if (canv_w % 2) { canv_w = canv_w - 1; }
|
||||||
|
|
||||||
{% if mobile_mode %}
|
{% if mobile_mode %}
|
||||||
var screen_h = window.outerHeight || window.innerHeight;
|
var screen_h = window.outerHeight || window.innerHeight;
|
||||||
canv_h = Math.min(canv_h, screen_h);
|
canv_h = Math.min(canv_h, screen_h);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
cc_canv[0].width = canv_w * dpi;
|
cc_canv[0].width = canv_w * dpi;
|
||||||
cc_canv[0].height = canv_h * dpi;
|
cc_canv[0].height = canv_h * dpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
var Module = {
|
var Module = {
|
||||||
preRun: [ preloadIndexedDB, resizeGameCanvas ],
|
preRun: [ preloadIndexedDB, resizeGameCanvas ],
|
||||||
postRun: [],
|
postRun: [],
|
||||||
arguments: {{game_args|safe}},
|
arguments: {{game_args|safe}},
|
||||||
print: function(text) {
|
print: function(text) {
|
||||||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
console.log(text);
|
console.log(text);
|
||||||
},
|
},
|
||||||
printErr: function(text) {
|
printErr: function(text) {
|
||||||
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
console.error(text);
|
console.error(text);
|
||||||
},
|
},
|
||||||
canvas: (function() { return document.getElementById('GameCanvas'); })(),
|
canvas: (function() { return document.getElementById('GameCanvas'); })(),
|
||||||
setStatus: function(text) {
|
setStatus: function(text) {
|
||||||
console.log(text);
|
console.log(text);
|
||||||
document.getElementById('logmsg').innerHTML = text;
|
document.getElementById('logmsg').innerHTML = text;
|
||||||
},
|
},
|
||||||
totalDependencies: 0,
|
totalDependencies: 0,
|
||||||
monitorRunDependencies: function(left) {
|
monitorRunDependencies: function(left) {
|
||||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||||
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Module.setStatus('Downloading...');
|
Module.setStatus('Downloading...');
|
||||||
window.onerror = function(event) {
|
window.onerror = function(event) {
|
||||||
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus
|
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus
|
||||||
Module.setStatus('Exception thrown, see JavaScript console');
|
Module.setStatus('Exception thrown, see JavaScript console');
|
||||||
Module.setStatus = function(text) {
|
Module.setStatus = function(text) {
|
||||||
if (text) Module.printErr('[post-exception status] ' + text);
|
if (text) Module.printErr('[post-exception status] ' + text);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<script async type="text/javascript" src="/static/classisphere.js"></script>
|
<script async type="text/javascript" src="/static/classisphere.js"></script>
|
||||||
|
</div>
|
||||||
{% if mobile_mode %}
|
</body>
|
||||||
<style>
|
</html>
|
||||||
#body {min-height: 0px;}
|
|
||||||
.sec {padding: 0px;}
|
|
||||||
.row {padding: 0px;}
|
|
||||||
</style>
|
|
||||||
{% else %}
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### static/classisphere.js
|
#### static/classisphere.js
|
||||||
Download `classicube.s3.amazonaws.com/client/latest/ClassiCube.js` for this
|
Download `cs.classicube.net/c_client/latest/ClassiCube.js` for this
|
||||||
|
|
||||||
#### static/default.zip
|
#### static/default.zip
|
||||||
Download `classicube.net/static/default.zip` for this
|
Download `classicube.net/static/default.zip` for this
|
||||||
@ -226,7 +194,7 @@ Download some version of jQuery for this. Version 2.1.1 is known to work.
|
|||||||
|
|
||||||
* If you don't want the game to resize to fit different resolutions, remove the `resizeGameCanvas` code.
|
* If you don't want the game to resize to fit different resolutions, remove the `resizeGameCanvas` code.
|
||||||
|
|
||||||
* tmpl_lite.html and mobile_mode is used to deliver a minified page for mobile/tablet devices
|
* mobile_mode is used to deliver a minified page for mobile/tablet devices
|
||||||
|
|
||||||
## Results
|
## Results
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
So you want to host your own version of the webclient? It's pretty easy to do, you need 3 files:
|
So you want to host your own version of the webclient? It's pretty easy to do, you need 3 files:
|
||||||
1) The game .js file
|
1) A web page to initialise the .js and display the game
|
||||||
2) A web page to initialise the .js and display the game
|
2) The game .js file
|
||||||
3) The default texture pack
|
3) The default texture pack
|
||||||
|
|
||||||
### Example setup
|
### Example setup
|
||||||
@ -11,8 +11,8 @@ For example, let's assume our site is setup like this:
|
|||||||
* `example.com/static/default.zip`
|
* `example.com/static/default.zip`
|
||||||
|
|
||||||
For simplicitly,
|
For simplicitly,
|
||||||
1) Download `classicube.net/static/classicube.js`, then upload it to `static/classisphere.js` on the webserver
|
1) Download `cs.classicube.net/c_client/latest/classicube.js`, then upload it to `static/classisphere.js` on the webserver
|
||||||
2) Download `classicube.net/static/default.zip`, then upload it to `static/default.zip` on the webserver
|
2) Download `classicube.net/static/default.zip`, then upload it to `static/default.zip` on the webserver
|
||||||
|
|
||||||
The play.html page is the trickiest part, because how to implement this is website-specific. (depends on how your website is styled, what webserver you use, what programming language is used to generate the html, etc)
|
The play.html page is the trickiest part, because how to implement this is website-specific. (depends on how your website is styled, what webserver you use, what programming language is used to generate the html, etc)
|
||||||
|
|
||||||
|
12
src/Logger.c
12
src/Logger.c
@ -651,31 +651,31 @@ void Logger_Abort2(cc_result result, const char* raw_msg) {
|
|||||||
AbortCommon(result, raw_msg, NULL);
|
AbortCommon(result, raw_msg, NULL);
|
||||||
}
|
}
|
||||||
#elif defined CC_BUILD_WIN
|
#elif defined CC_BUILD_WIN
|
||||||
static LONG WINAPI UnhandledFilter(struct _EXCEPTION_POINTERS* pInfo) {
|
static LONG WINAPI UnhandledFilter(struct _EXCEPTION_POINTERS* info) {
|
||||||
String msg; char msgBuffer[128 + 1];
|
String msg; char msgBuffer[128 + 1];
|
||||||
cc_uint32 code;
|
cc_uint32 code;
|
||||||
cc_uintptr addr;
|
cc_uintptr addr;
|
||||||
DWORD i, numArgs;
|
DWORD i, numArgs;
|
||||||
|
|
||||||
code = (cc_uint32)pInfo->ExceptionRecord->ExceptionCode;
|
code = (cc_uint32)info->ExceptionRecord->ExceptionCode;
|
||||||
addr = (cc_uintptr)pInfo->ExceptionRecord->ExceptionAddress;
|
addr = (cc_uintptr)info->ExceptionRecord->ExceptionAddress;
|
||||||
|
|
||||||
String_InitArray_NT(msg, msgBuffer);
|
String_InitArray_NT(msg, msgBuffer);
|
||||||
String_Format2(&msg, "Unhandled exception 0x%h at 0x%x", &code, &addr);
|
String_Format2(&msg, "Unhandled exception 0x%h at 0x%x", &code, &addr);
|
||||||
|
|
||||||
numArgs = pInfo->ExceptionRecord->NumberParameters;
|
numArgs = info->ExceptionRecord->NumberParameters;
|
||||||
if (numArgs) {
|
if (numArgs) {
|
||||||
numArgs = min(numArgs, EXCEPTION_MAXIMUM_PARAMETERS);
|
numArgs = min(numArgs, EXCEPTION_MAXIMUM_PARAMETERS);
|
||||||
String_AppendConst(&msg, " [");
|
String_AppendConst(&msg, " [");
|
||||||
|
|
||||||
for (i = 0; i < numArgs; i++) {
|
for (i = 0; i < numArgs; i++) {
|
||||||
String_Format1(&msg, "0x%x,", &pInfo->ExceptionRecord->ExceptionInformation[i]);
|
String_Format1(&msg, "0x%x,", &info->ExceptionRecord->ExceptionInformation[i]);
|
||||||
}
|
}
|
||||||
String_Append(&msg, ']');
|
String_Append(&msg, ']');
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.buffer[msg.length] = '\0';
|
msg.buffer[msg.length] = '\0';
|
||||||
AbortCommon(0, msg.buffer, pInfo->ContextRecord);
|
AbortCommon(0, msg.buffer, info->ContextRecord);
|
||||||
return EXCEPTION_EXECUTE_HANDLER; /* TODO: different flag */
|
return EXCEPTION_EXECUTE_HANDLER; /* TODO: different flag */
|
||||||
}
|
}
|
||||||
void Logger_Hook(void) { SetUnhandledExceptionFilter(UnhandledFilter); }
|
void Logger_Hook(void) { SetUnhandledExceptionFilter(UnhandledFilter); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user