Permalink
Browse files

Fix /client model being broken

  • Loading branch information...
UnknownShadow200 committed Dec 2, 2018
1 parent 1513a20 commit 40cadd9316648cdb68c05f750a376c4c3bc808fd
Showing with 563 additions and 16 deletions.
  1. +5 −1 ClassicalSharp/Commands/Commands.cs
  2. +4 −0 src/ClassiCube.vcxproj
  3. +12 −0 src/ClassiCube.vcxproj.filters
  4. +149 −0 src/LScreens.c
  5. +41 −0 src/LScreens.h
  6. +277 −0 src/LWeb.c
  7. +30 −0 src/LWeb.h
  8. +26 −13 src/LWidgets.c
  9. +17 −2 src/LWidgets.h
  10. +2 −0 src/Launcher.h
@@ -129,7 +129,11 @@ public sealed class ModelCommand : Command {
}
public override void Execute(string[] args) {
foreach (IGameComponent comp in game.Components) { comp.Dispose(); }
if (args.Length == 1) {
game.Chat.Add("&e/client model: &cYou didn't specify a model name.");
} else {
game.LocalPlayer.SetModel(args[1]);
}
}
}
@@ -210,6 +210,8 @@
<ClInclude Include="Gui.h" />
<ClInclude Include="HeldBlockRenderer.h" />
<ClInclude Include="Launcher.h" />
<ClInclude Include="LScreens.h" />
<ClInclude Include="LWeb.h" />
<ClInclude Include="LWidgets.h" />
<ClInclude Include="Model.h" />
<ClInclude Include="Input.h" />
@@ -273,6 +275,8 @@
<ClCompile Include="InputHandler.c" />
<ClCompile Include="Inventory.c" />
<ClCompile Include="Launcher.c" />
<ClCompile Include="LScreens.c" />
<ClCompile Include="LWeb.c" />
<ClCompile Include="LWidgets.c" />
<ClCompile Include="MapGenerator.c" />
<ClCompile Include="Deflate.c" />
@@ -312,6 +312,12 @@
<ClInclude Include="LWidgets.h">
<Filter>Header Files\Launcher</Filter>
</ClInclude>
<ClInclude Include="LWeb.h">
<Filter>Header Files\Launcher</Filter>
</ClInclude>
<ClInclude Include="LScreens.h">
<Filter>Header Files\Launcher</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="String.c">
@@ -557,5 +563,11 @@
<ClCompile Include="LWidgets.c">
<Filter>Source Files\Launcher</Filter>
</ClCompile>
<ClCompile Include="LWeb.c">
<Filter>Source Files\Launcher</Filter>
</ClCompile>
<ClCompile Include="LScreens.c">
<Filter>Source Files\Launcher</Filter>
</ClCompile>
</ItemGroup>
</Project>
@@ -0,0 +1,149 @@
#include "LScreens.h"
#include "LWidgets.h"
#include "Launcher.h"
#include "Gui.h"
static void LScreen_NullFunc(struct LScreen* s) { }
static void LScreen_DrawAll(struct LScreen* s) {
struct LWidget* widget;
int i;
for (i = 0; i < s->NumWidgets; i++) {
widget = s->Widgets[i];
widget->VTABLE->Redraw(widget);
}
}
static void LScreen_HoverWidget(struct LScreen* s, struct LWidget* w) {
if (!w) return;
w->Hovered = true;
if (w->VTABLE->OnHover) w->VTABLE->OnHover(w);
}
static void LScreen_UnhoverWidget(struct LScreen* s, struct LWidget* w) {
if (!w) return;
w->Hovered = false;
if (w->VTABLE->OnUnhover) w->VTABLE->OnUnhover(w);
}
CC_NOINLINE static void LScreen_Reset(struct LScreen* s) {
int i;
s->Init = NULL; /* screens should always override this */
s->Free = LScreen_NullFunc;
s->DrawAll = LScreen_DrawAll;
s->Tick = LScreen_NullFunc;
s->OnDisplay = LScreen_NullFunc;
s->HoverWidget = LScreen_HoverWidget;
s->UnhoverWidget = LScreen_UnhoverWidget;
/* reset all widgets to unselected */
for (i = 0; i < s->NumWidgets; i++) {
s->Widgets[i]->Hovered = false;
}
}
/*########################################################################################################################*
*---------------------------------------------------------Widget init-----------------------------------------------------*
*#########################################################################################################################*/
CC_NOINLINE static void LScreen_Button(struct LScreen* s, struct LButton* w, int width, int height, const char* text,
uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) {
String str = String_FromReadonly(text);
LButton_Init(w, width, height);
LButton_SetText(w, &str, &Launcher_TitleFont);
w->Hovered = false;
s->Widgets[s->NumWidgets++] = (struct LWidget*)w;
LWidget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
}
CC_NOINLINE static void LScreen_Label(struct LScreen* s, struct LLabel* w, const char* text,
uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) {
String str = String_FromReadonly(text);
LLabel_Init(w);
LLabel_SetText(w, &str, &Launcher_TextFont);
w->Hovered = false;
s->Widgets[s->NumWidgets++] = (struct LWidget*)w;
LWidget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
}
CC_NOINLINE static void LScreen_Slider(struct LScreen* s, struct LSlider* w, int width, int height,
int initValue, int maxValue, BitmapCol progressCol,
uint8_t horAnchor, uint8_t verAnchor, int xOffset, int yOffset) {
LSlider_Init(w, width, height);
w->Value = initValue; w->MaxValue = maxValue;
w->ProgressCol = progressCol;
w->Hovered = false;
s->Widgets[s->NumWidgets++] = (struct LWidget*)w;
LWidget_SetLocation(w, horAnchor, verAnchor, xOffset, yOffset);
}
/*########################################################################################################################*
*--------------------------------------------------------SettingsScreen---------------------------------------------------*
*#########################################################################################################################*/
/*static struct SettingsScreen {
LScreen_Layout
struct LWidget* Widgets[7];
struct LButton BtnUpdates, BtnMode, BtnColours, BtnBack;
struct LLabel LblUpdates, LblMode, LblColours;
} SettingsScreen_Instance;
static void SettingsScreen_InitWidgets(struct SettingsScreen* s) {
struct LScreen* s_ = (struct LScreen*)s;
LScreen_Button(s_, &s->BtnUpdates, 110, 35, "Updates",
ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -120);
LScreen_Label(s_, &s->LblUpdates, "&eGet the latest stuff",
ANCHOR_CENTRE, ANCHOR_CENTRE, 10, -120);
LScreen_Button(s_, &s->BtnMode, 110, 35, "Mode",
ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -70);
LScreen_Label(s_, &s->LblMode, "&eChange the enabled features",
ANCHOR_CENTRE, ANCHOR_CENTRE, 55, -70);
LScreen_Button(s_, &s->BtnColours, 110, 35, "Colours",
ANCHOR_CENTRE, ANCHOR_CENTRE, -135, -20);
LScreen_Label(s_, &s->LblColours, "&eChange how the launcher looks",
ANCHOR_CENTRE, ANCHOR_CENTRE, 65, -20);
LScreen_Button(s_, &s->BtnBack, 80, 35, "Back",
ANCHOR_CENTRE, ANCHOR_CENTRE, 0, 170);
}
static void SwitchToChooseMode(void* w, int x, int y) {
Launcher_SetScreen(ChooseModeScreen_MakeInstance(false));
}
static void SwitchToUpdates(void* w, int x, int y) {
Launcher_SetScreen(UpdatesScreen_MakeInstance());
}
static void SwitchToColours(void* w, int x, int y) {
Launcher_SetScreen(ColoursScreen_MakeInstance());
}
static void SwitchToMain(void* w, int x, int y) {
Launcher_SetScreen(MainScreen_MakeInstance());
}
static void SettingsScreen_Init(struct LScreen* s_) {
struct SettingsScreen* s = (struct SettingsScreen*)s_;
if (!s->NumWidgets) SettingsScreen_InitWidgets(s);
s->BtnColours.Hidden = Launcher_ClassicBackground;
s->LblColours.Hidden = Launcher_ClassicBackground;
s->BtnMode.OnClick = SwitchToChooseMode;
s->BtnUpdates.OnClick = SwitchToUpdates;
s->BtnColours.OnClick = SwitchToColours;
s->BtnBack.OnClick = SwitchToMain;
s->DrawAll(s);
}
struct LScreen* SettingsScreen_MakeInstance(void) {
struct SettingsScreen* s = &SettingsScreen_Instance;
LScreen_Reset((struct LScreen*)s);
s->Init = SettingsScreen_Init;
return (struct LScreen*)s;
}
*/
@@ -0,0 +1,41 @@
#ifndef CC_LSCREENS_H
#define CC_LSCREENS_H
#include "AsyncDownloader.h"
#include "String.h"
/* Implements screens/menus for the launcher.
Copyright 2014-2017 ClassicalSharp | Licensed under BSD-3
*/
struct LWidget;
struct LScreen;
typedef void (*LScreen_Func)(struct LScreen* s);
typedef void (*LWidget_Func)(struct LScreen* s, struct LWidget* w);
#define LScreen_Layout \
LScreen_Func Init; /* Initialises widgets and other data. */ \
LScreen_Func Free; /* Cleans up all native resources. */ \
LScreen_Func DrawAll; /* Redraws all widgets. */ \
LScreen_Func Tick; /* Repeatedly called multiple times every second. */ \
LScreen_Func OnDisplay; /* Called when framebuffer is about to be displayed. */ \
LWidget_Func HoverWidget; /* Called when mouse is moved over a given widget. */ \
LWidget_Func UnhoverWidget; /* Called when the mouse is moved away from a previously hovered widget. */ \
struct LWidget* HoveredWidget; /* Widget the mouse is currently hovering over. */ \
int NumWidgets; /* Number of widgets actually used. */
struct LScreen {
LScreen_Layout
/* All widgets in the screen. */
/* NOTE: This is vriable sized, so must be the last member. */
/* (e.g. derived screens might use: struct LWidget* Widgets[10];) */
struct LWidget** Widgets;
};
struct LScreen* ChooseModeScreen_MakeInstance(void);
struct LScreen* ColoursScreen_MakeInstance(void);
struct LScreen* DirectConnectScreen_MakeInstance(void);
struct LScreen* MainScreen_MakeInstance(void);
struct LScreen* ResourcesScreen_MakeInstance(void);
struct LScreen* ServersScreen_MakeInstance(void);
struct LScreen* SettingsScreen_MakeInstance(void);
struct LScreen* UpdateScreen_MakeInstance(void);
#endif
Oops, something went wrong.

0 comments on commit 40cadd9

Please sign in to comment.