Skip to content
This repository was archived by the owner on Mar 20, 2022. It is now read-only.

Commit 482d6a8

Browse files
committed
v0.12.0 I guess
1 parent b8a2062 commit 482d6a8

File tree

9 files changed

+62
-41
lines changed

9 files changed

+62
-41
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@
2121
#
2222

2323
ifdef USE_CLANG
24+
ifeq ($(origin CC),default)
2425
CC:=clang
25-
ARM_CC:=clang -target arm-linux-gnueabihf
26+
endif
27+
STRIP?=llvm-strip
2628
LDFLAGS:=-fuse-ld=lld
27-
STRIP:=llvm-strip
28-
ARM_STRIP:=${STRIP}
2929
ARCH:=$(shell $(CC) -dumpmachine | grep -Eo "arm|aarch|86|x86_64")
3030
else
31+
ifeq ($(origin CC),default)
3132
CC:=gcc
32-
ARM_CC:=arm-linux-gnueabihf-gcc
33+
endif
34+
STRIP?=strip
3335
LDFLAGS:=
34-
STRIP:=strip
35-
ARM_STRIP:=arm-linux-gnueabihf-strip
3636
ARCH:=$(shell $(CC) -print-multiarch | grep -Eo "arm|aarch|86|x86_64")
3737
endif
3838

3939
VERSION:=0.12.0
4040

4141
OBJS:=$(patsubst %,build/%.o,mcpil config features play servers)
4242

43-
CFLAGS:=-DGMCPIL_VERSION=\"v$(VERSION)\" -I./src/include -Wall -Wno-address-of-packed-member -Wno-pointer-to-int-cast -Wno-unused-result
43+
CFLAGS+=-DGMCPIL_VERSION=\"v$(VERSION)\" -I./src/include -Wall -Wno-address-of-packed-member -Wno-pointer-to-int-cast -Wno-unused-result
4444
CFLAGS+=$(shell pkg-config --cflags gtk+-3.0 json-glib-1.0)
4545
LDFLAGS+=-Wl,--no-undefined $(shell pkg-config --libs gtk+-3.0 json-glib-1.0)
4646

res/doc/gmcpil/CHANGELOG.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v0.12.0:
2+
+ New, fancy GUI.
3+
+ Lots of "refactoring".
4+
15
v0.11.1:
26
+ Internal code changes.
37
+ First official amd64 build.

screenshot.png

-1.92 KB
Loading

src/config.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*
2121
*/
2222

23+
#define _GNU_SOURCE /* Required for asprintf */
24+
2325
#include <stdio.h>
2426
#include <string.h>
2527

@@ -35,6 +37,7 @@ struct __attribute__((packed)) GMCPILConfigPrivate
3537
gchar* last_profile;
3638
gchar* hud;
3739
gchar* hide;
40+
gchar* last_featc;
3841
gchar* filename;
3942
};
4043

@@ -47,6 +50,7 @@ enum
4750
PROP_LAST_PROFILE,
4851
PROP_HUD,
4952
PROP_HIDE,
53+
PROP_LAST_FEATC,
5054
PROP_LAST
5155
};
5256

@@ -72,6 +76,7 @@ static void gmcpil_config_class_init(GMCPILConfigClass* klass)
7276
GMCPIL_GLIB_PROPERTY("last_profile", "Last profile", "Last selected profile", PROP_LAST_PROFILE);
7377
GMCPIL_GLIB_PROPERTY("hud", "Gallium HUD", "Gallium HUD options", PROP_HUD);
7478
GMCPIL_GLIB_PROPERTY("hide", "Hide launcher", "Hide launcher on launch", PROP_HIDE);
79+
GMCPIL_GLIB_PROPERTY("last_featc", "Last feature count", "Last MCPI-Reborn feature count", PROP_LAST_FEATC);
7580
return;
7681
}
7782

@@ -112,9 +117,10 @@ static void gmcpil_config_finalize(GObject* obj)
112117
GMCPIL_GETTER_SETTER(username);
113118
GMCPIL_GETTER_SETTER(features);
114119
GMCPIL_GETTER_SETTER(distance);
115-
GMCPIL_GETTER_SETTER(last_profile);
120+
GMCPIL_INT_GETTER_SETTER(last_profile);
116121
GMCPIL_GETTER_SETTER(hud);
117122
GMCPIL_GETTER_SETTER(hide);
123+
GMCPIL_INT_GETTER_SETTER(last_featc);
118124

119125
static void gmcpil_config_set_property(GObject* obj, guint prop_id, const GValue* value, GParamSpec* pspec)
120126
{

src/features.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ static int get_features()
6767
static int set_feature_envs(int feat)
6868
{
6969
int i = 0;
70-
static int sz[3] = {1, 1, 1};
71-
static int len[3] = {0, 0, 0};
72-
static int tmp[3] = {0, 0, 0};
70+
int sz[3] = {1, 1, 1};
71+
int len[3] = {0, 0, 0};
72+
int tmp[3] = {0, 0, 0};
7373

7474
while (i < 3)
7575
{
@@ -78,16 +78,13 @@ static int set_feature_envs(int feat)
7878
i++;
7979
continue;
8080
}
81-
if (i == 2)
81+
if (i == 2 && (FEAT_CMP(feat, "Fancy Graphics")
82+
|| FEAT_CMP(feat, "Smooth Lighting")
83+
|| FEAT_CMP(feat, "Animated Water")
84+
|| FEAT_CMP(feat, "Disable gui_blocks Atlas")))
8285
{
83-
if (FEAT_CMP(feat, "Fancy Graphics")
84-
|| FEAT_CMP(feat, "Smooth Lighting")
85-
|| FEAT_CMP(feat, "Animated Water")
86-
|| FEAT_CMP(feat, "Disable gui_blocks Atlas"))
87-
{
88-
i++;
89-
continue;
90-
}
86+
i++;
87+
continue;
9188
}
9289
if (FEAT_INT(feat) == TRUE || (i >= 2 && i <= 3 && FEAT_CMP(feat, "Force Mob Spawning")))
9390
{
@@ -178,6 +175,7 @@ static void toggle_cb(__attribute__((unused)) GtkWidget* check, void* udata)
178175
TAB(Features, features_cb, {
179176
int i = 0;
180177
int last_profile;
178+
int last_featc;
181179
char* tmp;
182180
char* features_buff;
183181
GtkWidget* feature_check;
@@ -187,6 +185,8 @@ TAB(Features, features_cb, {
187185

188186
featc = 0;
189187
featc = get_features();
188+
last_featc = gmcpil_config_get_last_featc(config);
189+
last_profile = gmcpil_config_get_last_profile(config);
190190

191191
features_envs[1] = (char*)malloc(1);
192192
features_envs[2] = (char*)malloc(1);
@@ -202,15 +202,15 @@ TAB(Features, features_cb, {
202202
if (features_buff != NULL)
203203
{
204204
i = 0;
205-
while (i < featc)
205+
while (i < last_featc)
206206
{
207207
FEAT_BOOL(i) = FALSE;
208208
i++;
209209
}
210210

211211
i = 0;
212212
tmp = strtok(features_buff, "|");
213-
while (tmp != NULL && i < featc)
213+
while (tmp != NULL && i < last_featc)
214214
{
215215
feature = get_feature(tmp);
216216
if (feature != NULL)
@@ -244,8 +244,8 @@ TAB(Features, features_cb, {
244244
}
245245

246246
features_cb(NULL, (void*)TRUE);
247+
gmcpil_config_set_last_featc(config, featc);
247248
gmcpil_config_set_features(config, features_envs[4]);
248-
last_profile = SAFE_ATOI(gmcpil_config_get_last_profile(config));
249249
setenv("MCPI_FEATURE_FLAGS", features_envs[last_profile], 1);
250250
gtk_container_add(GTK_CONTAINER(scroll), vbox);
251251
gtk_box_pack_start(GTK_BOX(tab), scroll, TRUE, TRUE, 0);

src/include/config.h

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ G_BEGIN_DECLS
3535

3636
#define VALID_JSON_ARGS(dst, name, parent) \
3737
(parent.node != NULL || dst != NULL || name != NULL || JSON_NODE_HOLDS_OBJECT(parent.node) || parent.obj == NULL)
38+
#define SAFE_ATOI(str) strtol(str ? str : "", NULL, 10)
3839

3940
#define GMCPIL_GETTER(name) gchar* gmcpil_config_get_ ## name (GMCPILConfig* self) \
4041
{ \
@@ -51,7 +52,26 @@ G_BEGIN_DECLS
5152
return; \
5253
}
5354

55+
#define GMCPIL_INT_GETTER(name) gint gmcpil_config_get_ ## name (GMCPILConfig* self) \
56+
{ \
57+
GMCPILConfigPrivate* private; \
58+
private = GMCPIL_CONFIG_PRIVATE(self); \
59+
return SAFE_ATOI(private->name); \
60+
}
61+
62+
#define GMCPIL_INT_SETTER(name) void gmcpil_config_set_ ## name (GMCPILConfig* self, const gint name) \
63+
{ \
64+
char* tmp; \
65+
GMCPILConfigPrivate* private; \
66+
asprintf(&tmp, "%i", name); \
67+
private = GMCPIL_CONFIG_PRIVATE(self); \
68+
private->name = g_strdup((gchar*)tmp); \
69+
free(tmp); \
70+
return; \
71+
}
72+
5473
#define GMCPIL_GETTER_SETTER(name) GMCPIL_GETTER(name); GMCPIL_SETTER(name);
74+
#define GMCPIL_INT_GETTER_SETTER(name) GMCPIL_INT_GETTER(name); GMCPIL_INT_SETTER(name);
5575

5676
#define GMCPIL_GLIB_PROPERTY(id, name, description, prop) \
5777
pspec = g_param_spec_string(id, name, description, NULL, G_PARAM_READWRITE); \
@@ -84,16 +104,18 @@ GMCPILConfig* gmcpil_config_new(gchar* filename);
84104
void gmcpil_config_set_username(GMCPILConfig* self, const gchar* username);
85105
void gmcpil_config_set_features(GMCPILConfig* self, const gchar* features);
86106
void gmcpil_config_set_distance(GMCPILConfig* self, const gchar* distance);
87-
void gmcpil_config_set_last_profile(GMCPILConfig* self, const gchar* last_profile);
107+
void gmcpil_config_set_last_profile(GMCPILConfig* self, const gint last_profile);
88108
void gmcpil_config_set_hud(GMCPILConfig* self, const gchar* hud);
89109
void gmcpil_config_set_hide(GMCPILConfig* self, const gchar* hide);
110+
void gmcpil_config_set_last_featc(GMCPILConfig* self, const gint last_featc);
90111

91112
gchar* gmcpil_config_get_username(GMCPILConfig* self);
92113
gchar* gmcpil_config_get_features(GMCPILConfig* self);
93114
gchar* gmcpil_config_get_distance(GMCPILConfig* self);
94-
gchar* gmcpil_config_get_last_profile(GMCPILConfig* self);
115+
gint gmcpil_config_get_last_profile(GMCPILConfig* self);
95116
gchar* gmcpil_config_get_hud(GMCPILConfig* self);
96117
gchar* gmcpil_config_get_hide(GMCPILConfig* self);
118+
gint gmcpil_config_get_last_featc(GMCPILConfig* self);
97119

98120
int gmcpil_config_save(GMCPILConfig* self);
99121

src/include/mcpil.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <config.h>
2828

2929
#define STR(str) #str
30-
#define SAFE_ATOI(str) strtol(str ? str : "", NULL, 10)
3130

3231
#define FEAT_BOOL(i) (features[i][0])
3332
#define FEAT_INT(i) ((int)features[i][0])
@@ -48,7 +47,6 @@
4847
g_signal_connect(button, "clicked", G_CALLBACK(button_cb), cb_udata); \
4948
return tab; \
5049
}
51-
//gtk_notebook_append_page(GTK_NOTEBOOK(notebook), tab, gtk_label_new(STR(name_str)));
5250

5351
#define GMCPIL_REPO_URL "https://github.com/MCPI-Revival/gMCPIL"
5452
#define GMCPIL_COPYRIGHT "Copyright 2021 MCPI-Revival contributors"

src/mcpil.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ void activate_cb(GtkApplication* app, __attribute__((unused)) void* udata)
9191
Play_tab(stack);
9292
Features_tab(stack);
9393
Servers_tab(stack);
94-
//Settings_tab(stack);
9594

9695
gtk_box_pack_start(GTK_BOX(switcher_box), switcher, TRUE, FALSE, 0);
9796
gtk_box_pack_end(GTK_BOX(switcher_box), about_button, TRUE, FALSE, 2);
@@ -116,7 +115,7 @@ int main(int argc, char* argv[])
116115
/* This is cursed, but it works:tm: */
117116
setenv("GTK_THEME", "Adwaita:dark", 1);
118117

119-
asprintf(&config_path, "%s/.minecraft-pi/gmcpil.json", getenv("HOME"));
118+
asprintf(&config_path, "%s/.gmcpil.json", getenv("HOME"));
120119
config = gmcpil_config_new(config_path);
121120
free(config_path);
122121

src/play.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,16 @@ static int get_distance(char* str)
6767
return -1;
6868
}
6969

70-
static void settings_cb(__attribute__((unused)) GtkWidget* button, void* udata)
70+
static void settings_cb(__attribute__((unused)) GtkWidget* button, __attribute__((unused)) void* udata)
7171
{
7272
int profile;
73-
char tmp[2] = {0x00, 0x00};
7473
const char* username;
7574
const char* distance;
7675
const char* hud;
7776
gboolean hide;
7877
GtkEntryBuffer* username_buff;
7978
GtkEntryBuffer* hud_buff;
8079

81-
if ((int)udata == TRUE)
82-
{
83-
goto profile;
84-
}
85-
8680
username_buff = gtk_entry_get_buffer(GTK_ENTRY(settings_box.username_entry));
8781
hud_buff = gtk_entry_get_buffer(GTK_ENTRY(settings_box.hud_entry));
8882

@@ -106,12 +100,10 @@ static void settings_cb(__attribute__((unused)) GtkWidget* button, void* udata)
106100
gmcpil_config_set_hide(config, "FALSE");
107101
}
108102

109-
profile:
110103
profile = gtk_combo_box_get_active(GTK_COMBO_BOX(settings_box.profile_combo));
111104
setenv("MCPI_FEATURE_FLAGS", features_envs[profile], 1);
112-
tmp[0] = profile + 0x30;
113105

114-
gmcpil_config_set_last_profile(config, tmp);
106+
gmcpil_config_set_last_profile(config, profile);
115107
gmcpil_config_save(config);
116108
return;
117109
}
@@ -129,7 +121,7 @@ static void launch_cb(__attribute__((unused)) GtkWidget* button, __attribute__((
129121
GPid pid;
130122
GError* err = NULL;
131123

132-
settings_cb(NULL, (void*)(intptr_t)TRUE);
124+
settings_cb(NULL, NULL);
133125
g_spawn_async(NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &err);
134126

135127
if (err != NULL)
@@ -226,7 +218,7 @@ TAB(Play, settings_cb, {
226218
profile_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
227219
profile_label = gtk_label_new("Profile");
228220
profile_combo = gtk_combo_box_text_new();
229-
last_profile = SAFE_ATOI(gmcpil_config_get_last_profile(config));
221+
last_profile = gmcpil_config_get_last_profile(config);
230222
while (i < 5)
231223
{
232224
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(profile_combo), profile_names[i]);

0 commit comments

Comments
 (0)