Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
MCPI-Docker compatibility, part 1.
Browse files Browse the repository at this point in the history
  • Loading branch information
torralbaa committed Oct 9, 2020
1 parent caf5079 commit a853500
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 56 deletions.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,27 @@

pack:
mkdir -p ./deb/
mkdir -p ./deb/DEBIAN/
cp -a ./res/. ./deb/
mkdir -p ./deb/usr/lib/python3/dist-packages/
mkdir -p ./deb/usr/bin/
cp ./src/mcpil.py ./deb/usr/bin/mcpil
cp ./src/mcpim.py ./deb/usr/lib/python3/dist-packages/
rm -f ./deb/usr/bin/mcpim
ln -s /usr/lib/python3/dist-packages/mcpim.py ./deb/usr/bin/mcpim
chmod a+x ./deb/usr/bin/mcpil
chmod a+x ./deb/usr/bin/mcpim
sudo chmod a+x ./deb/usr/bin/mcpil
sudo chmod a+x ./deb/usr/bin/mcpim
@echo "Package: mcpil" > ./deb/DEBIAN/control
@echo "Version: 0.7.0" >> ./deb/DEBIAN/control
@echo "Version: 0.7.1" >> ./deb/DEBIAN/control
@echo "Priority: optional" >> ./deb/DEBIAN/control
@echo "Architecture: armhf" >> ./deb/DEBIAN/control
@echo "Depends: libmcpi, mcpi-proxy, mcpi-central, libmodpi, libmcpi-docker, python3, minecraft-pi" >> ./deb/DEBIAN/control
@echo "Depends: libmcpi, mcpi-proxy, mcpi-central, libmodpi, libmcpi-docker, python3, libfreeimage3, libglfw3, minecraft-pi" >> ./deb/DEBIAN/control
@echo "Maintainer: Alvarito050506 <donfrutosgomez@gmail.com>" >> ./deb/DEBIAN/control
@echo "Homepage: https://mcpi.tk" >> ./deb/DEBIAN/control
@echo "Vcs-Browser: https://github.com/MCPI-Devs/MCPIL" >> ./deb/DEBIAN/control
@echo "Vcs-Git: https://github.com/MCPI-Devs/MCPIL.git" >> ./deb/DEBIAN/control
@echo "Description: Simple launcher for Minecraft: Pi Edition.\n" >> ./deb/DEBIAN/control
dpkg-deb -b ./deb/ ./mcpil_0.7.0-1.deb
dpkg-deb -b ./deb/ ./mcpil_0.7.1-1.deb

clean:
rm -rf ./deb/
Expand Down
13 changes: 0 additions & 13 deletions res/usr/bin/minecraft-pe.sh

This file was deleted.

15 changes: 0 additions & 15 deletions res/usr/bin/minecraft-pi.sh

This file was deleted.

64 changes: 41 additions & 23 deletions src/mcpil.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import time
import json
import threading
from os import environ, kill, rename, mkdir, uname, getpid
from os import environ, kill, rename, mkdir, uname, getpid, chdir
from tkinter import *
from tkinter import ttk
from tkinter import simpledialog
Expand All @@ -42,16 +42,28 @@

descriptions = [
"Classic Miecraft Pi Edition.\nNo mods.",
"Modded Miecraft Pi Edition.\nModPi + libmcpi-docker without Survival or Touch GUI.",
"Minecraft Pocket Edition.\nlibmcpi-docker.",
"Modded Miecraft Pi Edition.\nModPi + MCPI-Docker mods without Survival or Touch GUI.",
"Minecraft Pocket Edition.\nMCPI-Docker mods.",
"Custom Profile.\nModify its settings in the Profile tab.",
];
preset_features = [
str(),
"Fix Bow & Arrow|Fix Attacking|Mob Spawning|Show Clouds|ModPi",
"Touch GUI|Survival Mode|Fix Bow & Arrow|Fix Attacking|Mob Spawning|Show Clouds"
"Fix Bow & Arrow|Fix Attacking|Mob Spawning|Fancy Graphics|Fix Sign Placement|ModPi",
"Touch GUI|Survival Mode|Fix Bow & Arrow|Fix Attacking|Mob Spawning|Fancy Graphics|Disable Autojump By Default|Fix Sign Placement|Show Block Outlines"
];

features = [
"Touch GUI",
"Survival Mode",
"Fix Bow & Arrow",
"Fix Attacking",
"Mob Spawning",
"Fancy Graphics",
"Disable Autojump By Default",
"Fix Sign Placement",
"Show Block Outlines",
"ModPi"
];
features = ["Touch GUI", "Survival Mode", "Fix Bow & Arrow", "Fix Attacking", "Mob Spawning", "Show Clouds", "ModPi"];
enabled_features = str();
home = environ["HOME"];
api_client = APIClient(None);
Expand All @@ -61,7 +73,7 @@

class Checkbox(ttk.Checkbutton):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
super().__init__(*args, **kwargs);
self.state = BooleanVar(self);
self.configure(variable=self.state);

Expand All @@ -71,6 +83,15 @@ def checked(self):
def check(self, val):
return self.state.set(val);

class HyperLink(Label):
def __init__(self, parent, url, text=None, fg=None, cursor=None, *args, **kwargs):
self.url = url;
super().__init__(parent, text=(text or url), fg=(fg or "blue"), cursor=(cursor or "hand2"), *args, **kwargs);
self.bind("<Button-1>", self.web_open);

def web_open(self, event):
return webbrowser.open(self.url);

def basename(path):
return path.split("/")[-1];

Expand Down Expand Up @@ -99,6 +120,7 @@ def launch():
environ.update({
"LD_PRELOAD": f"/usr/lib/libmodpi.so:{bk}"
});
chdir("/opt/minecraft-pi");
mcpi_process = subprocess.Popen(["/opt/minecraft-pi/minecraft-pi"]);
environ.update({
"LD_PRELOAD": bk
Expand Down Expand Up @@ -171,10 +193,10 @@ def update_dlls():
global dll_files;

dll_files = list();
dll_files = glob("/usr/lib/mcpi-docker/mods/lib*.so");
dll_files = glob("/usr/lib/libmcpi-docker/lib*.so");
bk = environ.get("LD_LIBRARY_PATH") or str();
environ.update({
"LD_LIBRARY_PATH": f"/usr/lib/mcpi-docker:/usr/arm-linux-gnueabihf/lib:{bk}",
"LD_LIBRARY_PATH": f"/opt/minecraft-pi/minecraft-pi/lib/brcm:/usr/lib/libmcpi-docker:/usr/arm-linux-gnueabihf/lib:{bk}",
"LD_PRELOAD": ":".join(dll_files)
});
return 0;
Expand Down Expand Up @@ -206,10 +228,6 @@ def enable_central_server():
proxy_thread.start();
return 0;

def web_open(event):
webbrowser.open(event.widget.cget("text"));
return 0;

def save_world():
old_world_name = old_worldname_entry.get();
new_world_name = new_worldname_entry.get();
Expand Down Expand Up @@ -275,11 +293,15 @@ def restore_profile():
def add_checkboxes(parent):
global profile_settings;

i = 0;
profile_settings = list();
checkbox_frame = Frame(parent);
for feature in features:
tmp = Checkbox(parent, text=feature);
tmp.pack(fill=BOTH, pady=2, padx=160);
tmp = Checkbox(checkbox_frame, text=feature);
tmp.pack(fill=BOTH, anchor=N, padx=8);
profile_settings.append(tmp);
i += 1;
checkbox_frame.pack(fill=X);
return 0;

def init():
Expand Down Expand Up @@ -500,10 +522,7 @@ def profile_tab(parent):
title.config(font=("", 24));
title.pack();

checkbox_frame = Frame(tab);
add_checkboxes(checkbox_frame);
checkbox_frame.pack(fill=BOTH, pady=8, padx=16);

add_checkboxes(tab);
restore_profile();

buttons_frame = Frame(tab);
Expand All @@ -519,18 +538,17 @@ def about_tab(parent):
title.config(font=("", 24));
title.pack();

version = Label(tab, text="v0.6.2");
version = Label(tab, text="v0.7.1");
version.config(font=("", 10));
version.pack();

author = Label(tab, text="by @Alvarito050506");
author = HyperLink(tab, "https://github.com/Alvarito050506", text="by @Alvarito050506", fg="black");
author.config(font=("", 10));
author.pack();

url = Label(tab, text="https://github.com/MCPI-Devs/MCPIL", fg="blue", cursor="hand2");
url = HyperLink(tab, "https://github.com/MCPI-Devs/MCPIL");
url.config(font=("", 10));
url.pack();
author.bind("<Button-1>", web_open);
return tab;

def main(args):
Expand Down

0 comments on commit a853500

Please sign in to comment.