Skip to content

Commit

Permalink
Rename LAST to LibreSplit (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
wins1ey authored Jun 2, 2024
2 parents 318c78e + 81a99b6 commit a260630
Show file tree
Hide file tree
Showing 32 changed files with 794 additions and 748 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
with:
name: LAST-${{ env.build_number }}-${{ env.git_short_sha }}
path: LAST
name: LibreSplit-${{ env.build_number }}-${{ env.git_short_sha }}
path: libresplit
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Compiled files
LAST
libresplit
obj/
src/last-gtk.h
src/main.h

.vscode/
.cache/
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "resources"]
path = resources
url = https://github.com/wins1ey/LAST-resources
url = https://github.com/wins1ey/LibreSplit-resources
30 changes: 13 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BIN := LAST
BIN := libresplit

INC := `pkg-config --cflags gtk+-3.0 x11 jansson luajit`
CFLAGS := -std=gnu99 -O2 -pthread -Wall -Wno-unused-parameter
Expand All @@ -9,15 +9,15 @@ OBJ_DIR := ./obj

# Obtain list of source files and create list of object files
SOURCES := $(wildcard $(SRC_DIR)/*.c)
COMPONENTS := $(wildcard $(SRC_DIR)/components/*.c)
COMPONENTS := $(wildcard $(SRC_DIR)/component/*.c)
OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SOURCES)) \
$(patsubst $(SRC_DIR)/components/%.c, $(OBJ_DIR)/%.o, $(COMPONENTS))
$(patsubst $(SRC_DIR)/component/%.c, $(OBJ_DIR)/%.o, $(COMPONENTS))

DESTDIR :=
PREFIX := /usr/local
APP := last.desktop
ICON := last
SCHEMA := last.gschema.xml
APP := libresplit.desktop
ICON := libresplit
SCHEMA := libresplit.gschema.xml

ifdef DESTDIR
update_icon_cache :=
Expand All @@ -27,7 +27,7 @@ else
compile_schemas := glib-compile-schemas $(PREFIX)/share/glib-2.0/schemas
endif

all: last-gtk.h $(BIN)
all: main.h $(BIN)

# Rule to link object files to create executable
$(BIN): $(OBJECTS)
Expand All @@ -38,15 +38,14 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
gcc $(INC) $(CFLAGS) -c -o $@ $<

# Rule to compile C component source files to object files
$(OBJ_DIR)/%.o: $(SRC_DIR)/components/%.c | $(OBJ_DIR)
$(OBJ_DIR)/%.o: $(SRC_DIR)/component/%.c | $(OBJ_DIR)
gcc $(INC) $(CFLAGS) -c -o $@ $<

# Rule to create the object directory
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)

last-gtk.h: $(SRC_DIR)/last-gtk.css
xxd --include $(SRC_DIR)/last-gtk.css > $(SRC_DIR)/last-gtk.h || ($(RM) $(SRC_DIR)/last-gtk.h; false)
main.h: $(SRC_DIR)/main.css
xxd --include $(SRC_DIR)/main.css > $(SRC_DIR)/main.h || ($(RM) $(SRC_DIR)/main.h; false)

install: all
install -Dm755 $(BIN) $(DESTDIR)$(PREFIX)/bin/$(BIN)
Expand All @@ -56,13 +55,11 @@ install: all
rsvg-convert -w "$$size" -h "$$size" -f png -o $(DESTDIR)$(PREFIX)/share/icons/hicolor/"$$size"x"$$size"/apps/$(ICON).png $(ICON).svg ; \
done
$(update_icon_cache)
install -Dm644 $(SRC_DIR)/$(SCHEMA) $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/$(SCHEMA)
install -Dm644 $(SCHEMA) $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/$(SCHEMA)
$(compile_schemas)
install -Dm644 resources/themes/standard/standard.css $(DESTDIR)$(PREFIX)/share/LAST/themes/standard/standard.css
uninstall:
$(RM) $(DESTDIR)$(PREFIX)/bin/$(BIN)
$(RM) $(DESTDIR)$(PREFIX)/share/applications/$(APP)
$(RM) -r $(DESTDIR)$(PREFIX)/share/LAST
for size in 16 22 24 32 36 48 64 72 96 128 256 512; do \
$(RM) $(DESTDIR)$(PREFIX)/share/icons/hicolor/"$$size"x"$$size"/apps/$(ICON).png ; \
done
Expand All @@ -71,8 +68,7 @@ remove-schema:
$(RM) $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/$(SCHEMA)
$(compile_schemas)

# Clean target to remove object files and LAS executable
clean:
$(RM) -r $(BIN) $(OBJ_DIR) $(SRC_DIR)/last-gtk.h
$(RM) -r $(BIN) $(OBJ_DIR) $(SRC_DIR)/main.h

.PHONY: all last-gtk.h install uninstall remove-schema clean
.PHONY: all main.h install uninstall remove-schema clean
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# LAST <img src="https://github.com/wins1ey/LAST/assets/34382191/e81414b0-38b5-495f-ac9f-7510edd70547" width=32> Linux Auto Splitting Timer
# <img src="libresplit.svg" width=43 align=top> LibreSplit

LAST brings auto splitting functionality to [urn](https://github.com/3snowp7im/urn) with Lua-based auto splitters that are easy to port from asl.
LibreSplit brings auto splitting functionality to [urn](https://github.com/3snowp7im/urn) with Lua-based auto splitters that are easy to port from asl.

<img src="https://github.com/wins1ey/LAST/assets/34382191/2adfdae5-9a21-4bdf-a4c4-f1d5962a0b63" width=350>
<img src="https://github.com/wins1ey/LAST/assets/34382191/4455f57a-3d34-4fa3-9dff-2b342b6c56da" width=350>
<img src="https://github.com/wins1ey/LibreSplit/assets/34382191/2adfdae5-9a21-4bdf-a4c4-f1d5962a0b63" width=350>
<img src="https://github.com/wins1ey/LibreSplit/assets/34382191/4455f57a-3d34-4fa3-9dff-2b342b6c56da" width=350>

## Features

Expand All @@ -14,7 +14,7 @@ LAST brings auto splitting functionality to [urn](https://github.com/3snowp7im/u

## Dependencies

LAST requires the following dependencies on your system to compile:
LibreSplit requires the following dependencies on your system to compile:

- `libgtk+-3.0`
- `x11`
Expand All @@ -24,20 +24,20 @@ LAST requires the following dependencies on your system to compile:
## Installation

```bash
git clone --recurse-submodules https://github.com/wins1ey/LAST
cd LAST
git clone https://github.com/wins1ey/LibreSplit
cd LibreSplit
make
sudo make install
```
or
```bash
git clone --recurse-submodules https://github.com/wins1ey/LAST && cd LAST && make && sudo make install
git clone https://github.com/wins1ey/LibreSplit && cd LibreSplit && make && sudo make install
```

## Getting Started

1. Launch LAST by executing the compiled binary. `./LAST`
2. When first launched, LAST will create the `LAST` directory in your config directory. Auto splitters, splits and themes go in their respective folders inside.
1. Launch LibreSplit by executing the compiled binary. `./libresplit`
2. When first launched, LibreSplit will create the `libresplit` directory in your config directory. Auto splitters, splits and themes go in their respective folders inside.
3. The initial window is undecorated, but you can toggle window decorations by pressing the right Control key.
4. Control the timer using the following key presses:

Expand All @@ -55,7 +55,7 @@ git clone --recurse-submodules https://github.com/wins1ey/LAST && cd LAST && mak
| Page Up | Unsplit |
| Page Down | Skip split |

4. Customize keybindings by setting the values in `wildmouse.last` path with `gsettings`.
4. Customize keybindings by setting the values in `com.github.wins1ey.libresplit` path with `gsettings`.

| Key | Type | Description |
|----------------------------|---------|-----------------------------------|
Expand All @@ -76,11 +76,11 @@ Keybind strings should be parseable by

## Auto Splitters

LAST supports auto splitters written in Lua to automate split timing based on in-game events. When running LAST in the terminal you will initally be greeted with an auto splitter downloader which grabs them from [here](https://github.com/Wins1ey/LuaAutoSplitters). Feel free to make your own, Documentation can be found [here](./docs/AutoSplitters.md)
LibreSplit supports auto splitters written in Lua to automate split timing based on in-game events. Feel free to make your own, Documentation can be found [here](docs/auto-splitters.md)

## Split Files

Split files in LAST are stored as well-formed JSON. The split file must contain a main object. The following keys are optional:
Split files in LibreSplit are stored as well-formed JSON. The split file must contain a main object. The following keys are optional:

| Key | Value |
|---------------|---------------------------------------|
Expand All @@ -106,10 +106,10 @@ Times are strings in HH:MM:SS.mmmmmm format

## Themes

LAST supports customizable themes, allowing you to personalize the timer's appearance. To create a theme:
LibreSplit supports customizable themes, allowing you to personalize the timer's appearance. To create a theme:

1. Create a CSS stylesheet with your desired styles.
2. Place the stylesheet in the `~/.config/LAST/themes/<name>/<name>.css` directory. (If you have `XDG_CONFIG_HOME` env var pointing somewher else than .config it will be wherever it points to)
2. Place the stylesheet in the `~/.config/libresplit/themes/<name>/<name>.css` directory. (If you have `XDG_CONFIG_HOME` env var pointing somewher else than .config it will be wherever it points to)
3. Set the global theme by modifying the `theme` value in `gsettings`.
4. Theme variants should follow the pattern `<name>-<variant>.css`.
5. Individual splits can apply their own themes by specifying a `theme` key in the main split object.
Expand All @@ -118,7 +118,7 @@ For a list of supported CSS properties, refer to the [GtkCssProvider](https://de

## CSS Classes

The following CSS classes can be used to style the elements of the LAST interface:
The following CSS classes can be used to style the elements of the LibreSplit interface:

```css
.window
Expand Down
20 changes: 10 additions & 10 deletions docs/auto-splitters.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

* These work by reading into game's memory and determining when the timer should do something, like make a split.

* LAST's autosplitting system works in a very similar way to LiveSplit's. The main difference is that LAST uses Lua instead of C#. There are also some key differences:
* LibreSplit's autosplitting system works in a very similar way to LiveSplit's. The main difference is that LibreSplit uses Lua instead of C#. There are also some key differences:
* Runs an entire Lua system instead of only supporting specifically named C# blocks.
* This means you can run external functions outside of the ones LAST executes.
* This means you can run external functions outside of the ones LibreSplit executes.
* Support for the entire Lua language, including the importing of libraries for tasks such as performance monitoring.

# How to make LAST auto splitters
# How to make LibreSplit auto splitters

* It's somewhat easy if you know what you are doing or are porting an already existing one.

Expand All @@ -20,13 +20,13 @@
```lua
process('GameBlaBlaBla.exe')
```
* With this line, LAST will repeatedly attempt to find this process and will not continue script execution until it is found.
* With this line, LibreSplit will repeatedly attempt to find this process and will not continue script execution until it is found.

* Next we have to define the basic functions. Not all are required and the ones that are required may change depending on the game or end goal, like if loading screens are included or not.
* The order at which these run is the same as they are documented below.

### `startup`
The purpose of this function is to specify how many times LAST checks memory values and executes functions each second, the default is 60Hz. Usually, 60Hz is fine and this function can remain undefined. However, it's there if you need it.
The purpose of this function is to specify how many times LibreSplit checks memory values and executes functions each second, the default is 60Hz. Usually, 60Hz is fine and this function can remain undefined. However, it's there if you need it.
```lua
process('GameBlaBlaBla.exe')

Expand All @@ -53,7 +53,7 @@ function state()
end
```

* You may have noticed that we're assigning this `isLoading` variable with the result of the function `readAddress`. This function is part of LAST's Lua context and its purpose is to read memory values. It's explained in detail at the bottom of this document.
* You may have noticed that we're assigning this `isLoading` variable with the result of the function `readAddress`. This function is part of LibreSplit's Lua context and its purpose is to read memory values. It's explained in detail at the bottom of this document.

### `update`
The purpose of this function is to update local variables.
Expand Down Expand Up @@ -84,8 +84,8 @@ end
* We now have 3 variables, one represents the current state while the other the old state of isLoading, we also have loadCount getting updated in the `update` function which will store how many times we've entered the loading screen

### `start`
This tells LAST when to start the timer.\
_Note: LAST will ignore any start calls if the timer is running._
This tells LibreSplit when to start the timer.\
_Note: LibreSplit will ignore any start calls if the timer is running._
* Runs every 1000 / `refreshRate` milliseconds.
```lua
process('GameBlaBlaBla.exe')
Expand Down Expand Up @@ -116,7 +116,7 @@ end
```

### `split`
Tells LAST to execute a split whenever it gets a true return.
Tells LibreSplit to execute a split whenever it gets a true return.
* Runs every 1000 / `refreshRate` milliseconds.
```lua
process('GameBlaBlaBla.exe')
Expand Down Expand Up @@ -261,7 +261,7 @@ end
* In this example we are checking for the scene, of course, the address is completely arbitrary and doesnt mean anything for this example. Specifically we are checking if we are entering the MenuScene scene.

## readAddress
* `readAddress` is the second function that LAST defines for us and its globally available, its job is to read the memory value of a specified address.
* `readAddress` is the second function that LibreSplit defines for us and its globally available, its job is to read the memory value of a specified address.
* The first value defines what kind of value we will read:
1. `sbyte`: signed 8 bit integer
2. `byte`: unsigned 8 bit integer
Expand Down
6 changes: 3 additions & 3 deletions last.desktop → libresplit.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Name=LAST
Exec=LAST
Icon=last
Name=LibreSplit
Exec=libresplit
Icon=libresplit
Type=Application
Categories=GTK;GNOME;Utility;
4 changes: 2 additions & 2 deletions src/last.gschema.xml → libresplit.gschema.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema path="/wildmouse/last/" id="wildmouse.last">
<schema path="/com/github/wins1ey/libresplit/" id="com.github.wins1ey.libresplit">
<key name="start-decorated" type="b">
<default>false</default>
<summary>Start decorated</summary>
Expand Down Expand Up @@ -57,4 +57,4 @@
<description>Key for toggling window decorations.</description>
</key>
</schema>
</schemalist>
</schemalist>
File renamed without changes
16 changes: 8 additions & 8 deletions src/auto-splitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static const char* disabled_functions[] = {
"newproxy",
};

extern last_process process;
extern game_process process;

// I have no idea how this works
// https://stackoverflow.com/a/2336245
Expand All @@ -70,24 +70,24 @@ static void mkdir_p(const char *dir, __mode_t permissions) {

void check_directories()
{
char last_directory[PATH_MAX] = {0};
get_LAST_folder_path(last_directory);
char libresplit_directory[PATH_MAX] = {0};
get_libresplit_folder_path(libresplit_directory);

char auto_splitters_directory[PATH_MAX];
char themes_directory[PATH_MAX];
char splits_directory[PATH_MAX];

strcpy(auto_splitters_directory, last_directory);
strcpy(auto_splitters_directory, libresplit_directory);
strcat(auto_splitters_directory, "/auto-splitters");

strcpy(themes_directory, last_directory);
strcpy(themes_directory, libresplit_directory);
strcat(themes_directory, "/themes");

strcpy(splits_directory, last_directory);
strcpy(splits_directory, libresplit_directory);
strcat(splits_directory, "/splits");

// Make the LAST directory if it doesn't exist
mkdir_p(last_directory, 0755);
// Make the libresplit directory if it doesn't exist
mkdir_p(libresplit_directory, 0755);

// Make the autosplitters directory if it doesn't exist
if (mkdir(auto_splitters_directory, 0755) == -1) {
Expand Down
Loading

0 comments on commit a260630

Please sign in to comment.