attempt to fix mouse wheel issues and https skin issues

This commit is contained in:
UnknownShadow200 2019-04-20 18:11:58 +10:00
parent 9adf946c43
commit 42c8c036a3
4 changed files with 18 additions and 6 deletions

View File

@ -743,7 +743,7 @@ static void Http_WorkerLoop(void) {
#ifdef CC_BUILD_WEB #ifdef CC_BUILD_WEB
/* Access to XMLHttpRequest at 'http://static.classicube.net' from origin 'http://www.classicube.net' has been blocked by CORS policy: */ /* Access to XMLHttpRequest at 'http://static.classicube.net' from origin 'http://www.classicube.net' has been blocked by CORS policy: */
/* No 'Access-Control-Allow-Origin' header is present on the requested resource. */ /* No 'Access-Control-Allow-Origin' header is present on the requested resource. */
const static String skinServer = String_FromConst("http://www.classicube.net/static/skins/"); const static String skinServer = String_FromConst("/static/skins/");
#else #else
const static String skinServer = String_FromConst("http://static.classicube.net/skins/"); const static String skinServer = String_FromConst("http://static.classicube.net/skins/");
#endif #endif

View File

@ -123,6 +123,10 @@ void Options_SetString(const String* key, const String* value) {
EntryList_Set(&Options, key, value); EntryList_Set(&Options, key, value);
} }
#ifdef CC_BUILD_WEB
Options_Save();
#endif
if (Options_HasChanged(key)) return; if (Options_HasChanged(key)) return;
StringsBuffer_Add(&Options_Changed, key); StringsBuffer_Add(&Options_Changed, key);
} }

View File

@ -18,6 +18,7 @@
#include "Options.h" #include "Options.h"
#include "Logger.h" #include "Logger.h"
#ifndef CC_BUILD_WEB
#define LIQUID_ANIM_MAX 64 #define LIQUID_ANIM_MAX 64
/* Based off the incredible work from https://dl.dropboxusercontent.com/u/12694594/lava.txt /* Based off the incredible work from https://dl.dropboxusercontent.com/u/12694594/lava.txt
mirrored at https://github.com/UnknownShadow200/ClassicalSharp/wiki/Minecraft-Classic-lava-animation-algorithm mirrored at https://github.com/UnknownShadow200/ClassicalSharp/wiki/Minecraft-Classic-lava-animation-algorithm
@ -143,6 +144,7 @@ static void WaterAnimation_Tick(BitmapCol* ptr, int size) {
} }
} }
} }
#endif
/*########################################################################################################################* /*########################################################################################################################*
@ -237,11 +239,13 @@ static void Animations_Draw(struct AnimationData* data, TextureLoc texLoc, int s
Bitmap_Init(frame, size, size, ptr); Bitmap_Init(frame, size, size, ptr);
if (!data) { if (!data) {
#ifndef CC_BUILD_WEB
if (texLoc == 30) { if (texLoc == 30) {
LavaAnimation_Tick((BitmapCol*)frame.Scan0, size); LavaAnimation_Tick((BitmapCol*)frame.Scan0, size);
} else if (texLoc == 14) { } else if (texLoc == 14) {
WaterAnimation_Tick((BitmapCol*)frame.Scan0, size); WaterAnimation_Tick((BitmapCol*)frame.Scan0, size);
} }
#endif
} else { } else {
srcX = data->FrameX + data->State * size; srcX = data->FrameX + data->State * size;
Bitmap_CopyBlock(srcX, data->FrameY, 0, 0, &anims_bmp, &frame, size); Bitmap_CopyBlock(srcX, data->FrameY, 0, 0, &anims_bmp, &frame, size);
@ -262,8 +266,10 @@ static void Animations_Apply(struct AnimationData* data) {
data->Tick = data->TickDelay; data->Tick = data->TickDelay;
loc = data->TexLoc; loc = data->TexLoc;
#ifndef CC_BUILD_WEB
if (loc == 30 && anims_useLavaAnim) return; if (loc == 30 && anims_useLavaAnim) return;
if (loc == 14 && anims_useWaterAnim) return; if (loc == 14 && anims_useWaterAnim) return;
#endif
Animations_Draw(data, loc, data->FrameSize); Animations_Draw(data, loc, data->FrameSize);
} }
@ -316,6 +322,7 @@ static void Animations_Validate(void) {
static void Animations_Tick(struct ScheduledTask* task) { static void Animations_Tick(struct ScheduledTask* task) {
int i, size; int i, size;
#ifndef CC_BUILD_WEB
if (anims_useLavaAnim) { if (anims_useLavaAnim) {
size = min(Atlas2D.TileSize, 64); size = min(Atlas2D.TileSize, 64);
Animations_Draw(NULL, 30, size); Animations_Draw(NULL, 30, size);
@ -324,6 +331,7 @@ static void Animations_Tick(struct ScheduledTask* task) {
size = min(Atlas2D.TileSize, 64); size = min(Atlas2D.TileSize, 64);
Animations_Draw(NULL, 14, size); Animations_Draw(NULL, 14, size);
} }
#endif
if (!anims_count) return; if (!anims_count) return;
if (!anims_bmp.Scan0) { if (!anims_bmp.Scan0) {

View File

@ -4,6 +4,7 @@
#include "Event.h" #include "Event.h"
#include "Logger.h" #include "Logger.h"
#include "Funcs.h" #include "Funcs.h"
#include "ExtMath.h"
int Display_BitsPerPixel; int Display_BitsPerPixel;
Rect2D Display_Bounds; Rect2D Display_Bounds;
@ -2573,9 +2574,8 @@ static void Window_CorrectFocus(void) {
} }
static EM_BOOL Window_MouseWheel(int type, const EmscriptenWheelEvent* ev, void* data) { static EM_BOOL Window_MouseWheel(int type, const EmscriptenWheelEvent* ev, void* data) {
/* On my laptop, wheel movement of '1' is reported as '6.666666507' */ /* TODO: The scale factor isn't standardised.. is there a better way though? */
/* TODO: Verify this is the case on other platforms */ Mouse_SetWheel(Mouse_Wheel - Math_Sign(ev->deltaY));
Mouse_SetWheel(Mouse_Wheel - ev->deltaY / 6.666666507f);
Window_CorrectFocus(); Window_CorrectFocus();
return true; return true;
} }
@ -2734,7 +2734,7 @@ static EM_BOOL Window_KeyPress(int type, const EmscriptenKeyboardEvent* ev, void
} }
static void Window_HookEvents(void) { static void Window_HookEvents(void) {
emscripten_set_wheel_callback("#canvas", NULL, 0, Window_MouseWheel); emscripten_set_wheel_callback("#window", NULL, 0, Window_MouseWheel);
emscripten_set_mousedown_callback("#canvas", NULL, 0, Window_MouseButton); emscripten_set_mousedown_callback("#canvas", NULL, 0, Window_MouseButton);
emscripten_set_mouseup_callback("#canvas", NULL, 0, Window_MouseButton); emscripten_set_mouseup_callback("#canvas", NULL, 0, Window_MouseButton);
emscripten_set_mousemove_callback("#canvas", NULL, 0, Window_MouseMove); emscripten_set_mousemove_callback("#canvas", NULL, 0, Window_MouseMove);
@ -2752,7 +2752,7 @@ static void Window_HookEvents(void) {
} }
static void Window_UnhookEvents(void) { static void Window_UnhookEvents(void) {
emscripten_set_wheel_callback("#canvas", NULL, 0, NULL); emscripten_set_wheel_callback("#window", NULL, 0, NULL);
emscripten_set_mousedown_callback("#canvas", NULL, 0, NULL); emscripten_set_mousedown_callback("#canvas", NULL, 0, NULL);
emscripten_set_mouseup_callback("#canvas", NULL, 0, NULL); emscripten_set_mouseup_callback("#canvas", NULL, 0, NULL);
emscripten_set_mousemove_callback("#canvas", NULL, 0, NULL); emscripten_set_mousemove_callback("#canvas", NULL, 0, NULL);