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

Commit

Permalink
v0.12.0 I guess
Browse files Browse the repository at this point in the history
  • Loading branch information
torralbaalla committed Jul 17, 2021
1 parent b8a2062 commit 482d6a8
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 41 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@
#

ifdef USE_CLANG
ifeq ($(origin CC),default)
CC:=clang
ARM_CC:=clang -target arm-linux-gnueabihf
endif
STRIP?=llvm-strip
LDFLAGS:=-fuse-ld=lld
STRIP:=llvm-strip
ARM_STRIP:=${STRIP}
ARCH:=$(shell $(CC) -dumpmachine | grep -Eo "arm|aarch|86|x86_64")
else
ifeq ($(origin CC),default)
CC:=gcc
ARM_CC:=arm-linux-gnueabihf-gcc
endif
STRIP?=strip
LDFLAGS:=
STRIP:=strip
ARM_STRIP:=arm-linux-gnueabihf-strip
ARCH:=$(shell $(CC) -print-multiarch | grep -Eo "arm|aarch|86|x86_64")
endif

VERSION:=0.12.0

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

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

Expand Down
4 changes: 4 additions & 0 deletions res/doc/gmcpil/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.12.0:
+ New, fancy GUI.
+ Lots of "refactoring".

v0.11.1:
+ Internal code changes.
+ First official amd64 build.
Expand Down
Binary file modified screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*
*/

#define _GNU_SOURCE /* Required for asprintf */

#include <stdio.h>
#include <string.h>

Expand All @@ -35,6 +37,7 @@ struct __attribute__((packed)) GMCPILConfigPrivate
gchar* last_profile;
gchar* hud;
gchar* hide;
gchar* last_featc;
gchar* filename;
};

Expand All @@ -47,6 +50,7 @@ enum
PROP_LAST_PROFILE,
PROP_HUD,
PROP_HIDE,
PROP_LAST_FEATC,
PROP_LAST
};

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

Expand Down Expand Up @@ -112,9 +117,10 @@ static void gmcpil_config_finalize(GObject* obj)
GMCPIL_GETTER_SETTER(username);
GMCPIL_GETTER_SETTER(features);
GMCPIL_GETTER_SETTER(distance);
GMCPIL_GETTER_SETTER(last_profile);
GMCPIL_INT_GETTER_SETTER(last_profile);
GMCPIL_GETTER_SETTER(hud);
GMCPIL_GETTER_SETTER(hide);
GMCPIL_INT_GETTER_SETTER(last_featc);

static void gmcpil_config_set_property(GObject* obj, guint prop_id, const GValue* value, GParamSpec* pspec)
{
Expand Down
30 changes: 15 additions & 15 deletions src/features.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ static int get_features()
static int set_feature_envs(int feat)
{
int i = 0;
static int sz[3] = {1, 1, 1};
static int len[3] = {0, 0, 0};
static int tmp[3] = {0, 0, 0};
int sz[3] = {1, 1, 1};
int len[3] = {0, 0, 0};
int tmp[3] = {0, 0, 0};

while (i < 3)
{
Expand All @@ -78,16 +78,13 @@ static int set_feature_envs(int feat)
i++;
continue;
}
if (i == 2)
if (i == 2 && (FEAT_CMP(feat, "Fancy Graphics")
|| FEAT_CMP(feat, "Smooth Lighting")
|| FEAT_CMP(feat, "Animated Water")
|| FEAT_CMP(feat, "Disable gui_blocks Atlas")))
{
if (FEAT_CMP(feat, "Fancy Graphics")
|| FEAT_CMP(feat, "Smooth Lighting")
|| FEAT_CMP(feat, "Animated Water")
|| FEAT_CMP(feat, "Disable gui_blocks Atlas"))
{
i++;
continue;
}
i++;
continue;
}
if (FEAT_INT(feat) == TRUE || (i >= 2 && i <= 3 && FEAT_CMP(feat, "Force Mob Spawning")))
{
Expand Down Expand Up @@ -178,6 +175,7 @@ static void toggle_cb(__attribute__((unused)) GtkWidget* check, void* udata)
TAB(Features, features_cb, {
int i = 0;
int last_profile;
int last_featc;
char* tmp;
char* features_buff;
GtkWidget* feature_check;
Expand All @@ -187,6 +185,8 @@ TAB(Features, features_cb, {

featc = 0;
featc = get_features();
last_featc = gmcpil_config_get_last_featc(config);
last_profile = gmcpil_config_get_last_profile(config);

features_envs[1] = (char*)malloc(1);
features_envs[2] = (char*)malloc(1);
Expand All @@ -202,15 +202,15 @@ TAB(Features, features_cb, {
if (features_buff != NULL)
{
i = 0;
while (i < featc)
while (i < last_featc)
{
FEAT_BOOL(i) = FALSE;
i++;
}

i = 0;
tmp = strtok(features_buff, "|");
while (tmp != NULL && i < featc)
while (tmp != NULL && i < last_featc)
{
feature = get_feature(tmp);
if (feature != NULL)
Expand Down Expand Up @@ -244,8 +244,8 @@ TAB(Features, features_cb, {
}

features_cb(NULL, (void*)TRUE);
gmcpil_config_set_last_featc(config, featc);
gmcpil_config_set_features(config, features_envs[4]);
last_profile = SAFE_ATOI(gmcpil_config_get_last_profile(config));
setenv("MCPI_FEATURE_FLAGS", features_envs[last_profile], 1);
gtk_container_add(GTK_CONTAINER(scroll), vbox);
gtk_box_pack_start(GTK_BOX(tab), scroll, TRUE, TRUE, 0);
Expand Down
26 changes: 24 additions & 2 deletions src/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ G_BEGIN_DECLS

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

#define GMCPIL_GETTER(name) gchar* gmcpil_config_get_ ## name (GMCPILConfig* self) \
{ \
Expand All @@ -51,7 +52,26 @@ G_BEGIN_DECLS
return; \
}

#define GMCPIL_INT_GETTER(name) gint gmcpil_config_get_ ## name (GMCPILConfig* self) \
{ \
GMCPILConfigPrivate* private; \
private = GMCPIL_CONFIG_PRIVATE(self); \
return SAFE_ATOI(private->name); \
}

#define GMCPIL_INT_SETTER(name) void gmcpil_config_set_ ## name (GMCPILConfig* self, const gint name) \
{ \
char* tmp; \
GMCPILConfigPrivate* private; \
asprintf(&tmp, "%i", name); \
private = GMCPIL_CONFIG_PRIVATE(self); \
private->name = g_strdup((gchar*)tmp); \
free(tmp); \
return; \
}

#define GMCPIL_GETTER_SETTER(name) GMCPIL_GETTER(name); GMCPIL_SETTER(name);
#define GMCPIL_INT_GETTER_SETTER(name) GMCPIL_INT_GETTER(name); GMCPIL_INT_SETTER(name);

#define GMCPIL_GLIB_PROPERTY(id, name, description, prop) \
pspec = g_param_spec_string(id, name, description, NULL, G_PARAM_READWRITE); \
Expand Down Expand Up @@ -84,16 +104,18 @@ GMCPILConfig* gmcpil_config_new(gchar* filename);
void gmcpil_config_set_username(GMCPILConfig* self, const gchar* username);
void gmcpil_config_set_features(GMCPILConfig* self, const gchar* features);
void gmcpil_config_set_distance(GMCPILConfig* self, const gchar* distance);
void gmcpil_config_set_last_profile(GMCPILConfig* self, const gchar* last_profile);
void gmcpil_config_set_last_profile(GMCPILConfig* self, const gint last_profile);
void gmcpil_config_set_hud(GMCPILConfig* self, const gchar* hud);
void gmcpil_config_set_hide(GMCPILConfig* self, const gchar* hide);
void gmcpil_config_set_last_featc(GMCPILConfig* self, const gint last_featc);

gchar* gmcpil_config_get_username(GMCPILConfig* self);
gchar* gmcpil_config_get_features(GMCPILConfig* self);
gchar* gmcpil_config_get_distance(GMCPILConfig* self);
gchar* gmcpil_config_get_last_profile(GMCPILConfig* self);
gint gmcpil_config_get_last_profile(GMCPILConfig* self);
gchar* gmcpil_config_get_hud(GMCPILConfig* self);
gchar* gmcpil_config_get_hide(GMCPILConfig* self);
gint gmcpil_config_get_last_featc(GMCPILConfig* self);

int gmcpil_config_save(GMCPILConfig* self);

Expand Down
2 changes: 0 additions & 2 deletions src/include/mcpil.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <config.h>

#define STR(str) #str
#define SAFE_ATOI(str) strtol(str ? str : "", NULL, 10)

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

#define GMCPIL_REPO_URL "https://github.com/MCPI-Revival/gMCPIL"
#define GMCPIL_COPYRIGHT "Copyright 2021 MCPI-Revival contributors"
Expand Down
3 changes: 1 addition & 2 deletions src/mcpil.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ void activate_cb(GtkApplication* app, __attribute__((unused)) void* udata)
Play_tab(stack);
Features_tab(stack);
Servers_tab(stack);
//Settings_tab(stack);

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

asprintf(&config_path, "%s/.minecraft-pi/gmcpil.json", getenv("HOME"));
asprintf(&config_path, "%s/.gmcpil.json", getenv("HOME"));
config = gmcpil_config_new(config_path);
free(config_path);

Expand Down
16 changes: 4 additions & 12 deletions src/play.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,16 @@ static int get_distance(char* str)
return -1;
}

static void settings_cb(__attribute__((unused)) GtkWidget* button, void* udata)
static void settings_cb(__attribute__((unused)) GtkWidget* button, __attribute__((unused)) void* udata)
{
int profile;
char tmp[2] = {0x00, 0x00};
const char* username;
const char* distance;
const char* hud;
gboolean hide;
GtkEntryBuffer* username_buff;
GtkEntryBuffer* hud_buff;

if ((int)udata == TRUE)
{
goto profile;
}

username_buff = gtk_entry_get_buffer(GTK_ENTRY(settings_box.username_entry));
hud_buff = gtk_entry_get_buffer(GTK_ENTRY(settings_box.hud_entry));

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

profile:
profile = gtk_combo_box_get_active(GTK_COMBO_BOX(settings_box.profile_combo));
setenv("MCPI_FEATURE_FLAGS", features_envs[profile], 1);
tmp[0] = profile + 0x30;

gmcpil_config_set_last_profile(config, tmp);
gmcpil_config_set_last_profile(config, profile);
gmcpil_config_save(config);
return;
}
Expand All @@ -129,7 +121,7 @@ static void launch_cb(__attribute__((unused)) GtkWidget* button, __attribute__((
GPid pid;
GError* err = NULL;

settings_cb(NULL, (void*)(intptr_t)TRUE);
settings_cb(NULL, NULL);
g_spawn_async(NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &err);

if (err != NULL)
Expand Down Expand Up @@ -226,7 +218,7 @@ TAB(Play, settings_cb, {
profile_hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
profile_label = gtk_label_new("Profile");
profile_combo = gtk_combo_box_text_new();
last_profile = SAFE_ATOI(gmcpil_config_get_last_profile(config));
last_profile = gmcpil_config_get_last_profile(config);
while (i < 5)
{
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(profile_combo), profile_names[i]);
Expand Down

0 comments on commit 482d6a8

Please sign in to comment.