Skip to content

Commit

Permalink
Windows work
Browse files Browse the repository at this point in the history
  • Loading branch information
zmnpl committed Apr 19, 2021
1 parent ddeceee commit 73ecb7c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 25 deletions.
58 changes: 37 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# twad - terminal wad launcher

If you love __DOOM__ and love your terminal like me, then you might like this. **twad** is a terminal based WAD manager and launcher for doom source ports. At it's core twad lets you set up a multitude of WAD file combinations, store them and launch them with a couple of key strokes. It is light weight and blazing fast to use.
If you love __DOOM__ and love your terminal then **twad** is for you. **twad** is a terminal based WAD manager and launcher for doom source ports. At it's core twad lets you set up a multitude of WAD file combinations, store them and launch them with a couple of key strokes. It is light weight and fast to use.

## Start **classic DOOM** with a **classic terminal user interface**

Twad let's you stay in the terminal and on your keyboard as long as possible until you decide to **rip and tear**. Simple as that.

Needless to say that this mostly was designed for *nix systems. However, meanwhile I've added some OS-sensitive stuff and cross compiled for Windows. Actually it works quite well. So...
Twad let's you stay in the terminal and on your keyboard as long as possible until you decide to **rip and tear**. Simple as that. Needless to say that this mostly was designed for *nix systems. However, meanwhile I've added some OS-sensitive behaviour and cross compiled for Windows. Actually it works quite well. So...

## Now with experimental **Windows support**

**Watch Out**: This tool is still in early state and might contain bugs.

![demo](demo.gif)
![demo](readme_assets/demo.gif)

![demo on windows](readme_assets/twad_windows.png)

# Features

Expand All @@ -26,6 +26,7 @@ Needless to say that this mostly was designed for *nix systems. However, meanwhi
* Collect some stats from the cames console output as well as playtime and so on (not sending it anywhere)
* Collect stats from savegames
* Run games from rofi or dmenu
* Import .zip files containing mods
* Separate savegame / demo folders for games (in **~/.config/twad/...***)
* Responsive layout (kind of)

Expand Down Expand Up @@ -54,7 +55,13 @@ go get -u github.com/zmnpl/twad

***twad*** assumes, you have **one folder**, where your IWADs are located. All your pwads (mapsets, gameplay mods, ...) need to be in the same or subfolder of this. The folder, where you put your IWADs is known to source ports as **DOOMWADDIR**.

An example could look like this:
1) Setup your **DOOMWADDIR** as described above
2) twad's first start will ask you to configure your **DOOMWADDIR** in the options
3) Within twad create games
4) Add mods to your games
666) __Rip and Tear__

## An example could look like this
```bash
~/DOOM ❯❯❯ tree
.
Expand All @@ -73,30 +80,39 @@ An example could look like this:
├── doom2.wad
└── doom.wad
```
1) Setup your **DOOMWADDIR** as described above
2) twad's first start will ask you to configure your **DOOMWADDIR** in the options
3) Within twad create games
4) Add mods to your games
666) __Rip and Tear__

## Or this on Windows
```cmd
C:\DOOM\> dir
.
├── Ashes 2063
│   ├── Ashes2063Maps115.wad
│   └── Ashes2063Mod115.pk3
├── Back To Saturn X e1
│   ├── btsx_e1a.wad
│   ├── btsx_e1b.wad
│   └── btsx_e1.deh
├── D4T
│   └── D4Tv2.5.pk3
├── Sigil
│ ├── SIGIL_COMPAT.wad
│ └── SIGIL.wad
├── doom2.wad
└── doom.wad
```


## More on DOOMWADDIR

Your DOOM source port needs to know about the base folder of your mods and IWADs to work properly, since ***twad*** uses relative paths. ***twad**'s default method for this is to set the ***DOOMWADDIR*** environment variable when starting a game. This is only set for the current game session. (Should you already have set DOOMWADDIR, twad will shadow it with whatever is set in its configuration)
Your DOOM source port needs to know about the base folder of your mods and IWADs to work properly, since ***twad*** uses relative paths. ***twad***'s default method for this is to set the ***DOOMWADDIR*** environment variable when starting a game. This is only set for the current game session. (Should you already have set DOOMWADDIR, twad will shadow it with whatever is set in its configuration)

An alternative/additional method is to add paths to the respective source ports config. For *zdoom* ports it could look like this:
```bash
# in your doom engine .ini
[FileSearch.Directories]
PATH=/home/doomguy/Doom # path to DOOMWADDIR
PATH=/home/doomguy/DOOM # path to DOOMWADDIR
```

There is flag in the options which lets Twad try to do this automatically for these engines if it finds the respective config:
- **Zandronum** *(~/.config/zandronum/zandronum.ini)*
- **LZDoom** *(~/.config/lzdoom/lzdoom.ini)*
- **GZDoom** *(~/.config/gzdoom/gzdoom.ini)*

If you are using something different, please configure it accoridingly or send in an issue or pull request ;)

# Rofi Mode

You can use [***rofi***](https://github.com/davatorium/rofi) or [***dmenu***](https://tools.suckless.org/dmenu/) to launch your games. Run twad like this to use the respective programm. This will open rofi/dmenu and show a list of all games you already have. Select one you want to play and hit enter. Of course this will also track your statistics.
Expand All @@ -107,7 +123,7 @@ twad --dmenu
```
**For instant Rip & Tear** bind this to a keyboard shortcut

![rofimode](rofimode.png)
![rofimode](readme_assets/rofimode.png)


# Plans / Ideas
Expand Down
9 changes: 9 additions & 0 deletions games/game.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path"
"path/filepath"
"regexp"
"runtime"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -185,6 +186,11 @@ func (g *Game) getLaunchParams(rcfg runconfig) []string {
params = append(params, g.getSaveDir())
}

// stats for zdoom on windows
if sourcePortFamily(g.SourcePort) == zdoom && runtime.GOOS == "windows" {
params = append(params, "-stdout")
}

// stats for chocolate doom and ports
if sourcePortFamily(g.SourcePort) == chocolate {
params = append(params, "-statdump")
Expand Down Expand Up @@ -418,6 +424,9 @@ func (g *Game) Demos() ([]os.DirEntry, error) {
}
sort.Slice(demos, func(i, j int) bool {
foo, err := demos[i].Info()
if err != nil {
return false
}
bar, err := demos[j].Info()
if err != nil {
return true
Expand Down
6 changes: 2 additions & 4 deletions games/gameList.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ type GameList []Game
var (
once sync.Once
instance GameList
config *cfg.Cfg
changeListeners []func()
gamesJSONName = "games.json"
)

func init() {
config = cfg.Instance()
GetInstance()
changeListeners = make([]func(), 0)
}

// GetInstance sets up and returns the singleton instance of games
func GetInstance() GameList {
once.Do(func() {
instance = make(GameList, 0, 0)
instance = make(GameList, 0)
loadGames()
})
return instance
Expand Down Expand Up @@ -125,7 +123,7 @@ func loadGames() error {
return err
}

for i, _ := range instance {
for i := range instance {
go instance[i].ReadLatestStats()
}

Expand Down
File renamed without changes
File renamed without changes
Binary file added readme_assets/twad_windows.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73ecb7c

Please sign in to comment.