Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .envrc-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set -a
use nix
mkdir -p $TMPDIR
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ go.work
go.work.sum

# env file
.env
.envrc

# Our files
weidu*
Expand All @@ -40,3 +40,6 @@ infinity_dialog*
# Log files
debug.log
__debug*

# bins
infinity_dialog
5 changes: 1 addition & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
Expand All @@ -10,7 +7,7 @@
"request": "attach",
"mode": "remote",
"port": 2345,
"host": "127.0.0.1",
"host": "0.0.0.0",
"showLog": true
}
]
Expand Down
78 changes: 78 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Contributing to Mod Installer

First off, thank you for considering contributing to Mod Installer. It's people like you that make Mod Installer such a great tool.

## Code of Conduct

By participating in this project, you are expected to uphold our Code of Conduct. Please report unacceptable behavior to [PROJECT MAINTAINER EMAIL].

## How Can I Contribute?

### Reporting Bugs

This section guides you through submitting a bug report for Mod Installer. Following these guidelines helps maintainers and the community understand your report, reproduce the behavior, and find related reports.

- Use a clear and descriptive title for the issue to identify the problem.
- Describe the exact steps which reproduce the problem in as many details as possible.
- Provide specific examples to demonstrate the steps.

### Suggesting Enhancements

This section guides you through submitting an enhancement suggestion for Mod Installer, including completely new features and minor improvements to existing functionality.

- Use a clear and descriptive title for the issue to identify the suggestion.
- Provide a step-by-step description of the suggested enhancement in as many details as possible.
- Provide specific examples to demonstrate the steps.

### Pull Requests

- Fill in the required template
- Do not include issue numbers in the PR title
- Include screenshots and animated GIFs in your pull request whenever possible.
- Follow the Rust styleguides.
- Include thoughtfully-worded, well-structured tests.
- Document new code based on the Documentation Styleguide
- End all files with a newline

## Styleguides

### Git Commit Messages

- Use the present tense ("Add feature" not "Added feature")
- Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
- Limit the first line to 72 characters or less
- Reference issues and pull requests liberally after the first line
- Consider starting the commit message with an applicable emoji:
- 🎨 `:art:` when improving the format/structure of the code
- 🐎 `:racehorse:` when improving performance
- 🚱 `:non-potable_water:` when plugging memory leaks
- 📝 `:memo:` when writing docs
- 🐧 `:penguin:` when fixing something on Linux
- 🍎 `:apple:` when fixing something on macOS
- 🏁 `:checkered_flag:` when fixing something on Windows
- 🐛 `:bug:` when fixing a bug
- 🔥 `:fire:` when removing code or files
- 💚 `:green_heart:` when fixing the CI build
- ✅ `:white_check_mark:` when adding tests
- 🔒 `:lock:` when dealing with security
- ⬆️ `:arrow_up:` when upgrading dependencies
- ⬇️ `:arrow_down:` when downgrading dependencies

### Rust Styleguide

All Rust code should adhere to [Rust Style](https://doc.rust-lang.org/beta/style-guide/index.html) and be formatted using `cargo fmt`.

## Additional Notes

### Issue and Pull Request Labels

This section lists the labels we use to help us track and manage issues and pull requests.

* `bug` - Issues that are bugs.
* `enhancement` - Issues that are feature requests.
* `documentation` - Issues or pull requests related to documentation.
* `good first issue` - Good for newcomers.

### Thank you!

Your contributions to open source, large or small, make great projects like this possible. Thank you for taking the time to contribute.
2 changes: 1 addition & 1 deletion cmd/check-varriables.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (c *checkVariables) genRows() *[]table.Row {
}
}
out := []table.Row{}
for lang, _ := range rows {
for lang := range rows {
for filename, stringVariables := range largest {
size_for_lang := rows[lang][filename]
sliceDiff := util.SortedDifference(&stringVariables, &size_for_lang)
Expand Down
92 changes: 92 additions & 0 deletions cmd/dialogue-tree.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package cmd

import (
"strings"

"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/dark0dave/infinity_dialog/pkg/components"
"github.com/dark0dave/infinity_dialog/pkg/util"
)

type dialogueTree struct {
table table.Model
}

func NewDialogueTree() dialogueTree {
columns := []table.Column{
{Title: "FileName", Width: int(0.2 * float64(width))},
{Title: "Character Name", Width: int(0.2 * float64(width))},
{Title: "Value", Width: int(0.55 * float64(width))},
}

t := table.New(
table.WithColumns(columns),
table.WithFocused(true),
table.WithHeight(height-len(columns)+4),
)

s := table.DefaultStyles()
s.Header = s.Header.
BorderStyle(lipgloss.NormalBorder()).
BorderForeground(lipgloss.Color("240")).
BorderTop(true).
BorderBottom(true).
Bold(false)
s.Selected = s.Selected.
Foreground(lipgloss.Color("229")).
Background(lipgloss.Color("57")).
Bold(false)
t.SetStyles(s)

return dialogueTree{table: t}
}

func (d dialogueTree) Init() tea.Cmd {
return nil
}

func (d dialogueTree) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case SelectedFilePath:
// TODO: This only works on banter files
rows := []table.Row{}
files, err := util.ReadFiles(string(msg), "d")
for fileName, fileContents := range files {
for _, line := range *fileContents {
if strings.Contains(line, "/*") && (strings.Contains(line, "@") || strings.Contains(line, "==")) {
var characterName String
if strings.Contains(line, "@") && strings.Contains(line, "==") {
characterName = strings.Split(line, " ")[1]
}

rows = append(rows, table.Row{
fileName,
})
}
}
}
if err != nil {
return d, nil
}
d.table.SetRows(rows)
case tea.WindowSizeMsg:
h, w := docStyle.GetFrameSize()
components.DynamicalSetTableSize(&d.table, &msg, h, w)
case tea.KeyMsg:
switch msg.String() {
case "q", "esc":
return state.PreviousCommand(), nil
case "ctrl+c", "ctrl+d":
return d, tea.Quit
}
}
var cmd tea.Cmd
d.table, cmd = d.table.Update(msg)
return d, cmd
}

func (d dialogueTree) View() string {
return d.table.View()
}
14 changes: 6 additions & 8 deletions cmd/file-view.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ func NewFileView() fileview {
return f
}

func GetFileContents(path string) (string, string) {
func GetFileContents(path string) (*string, string) {
dir := filepath.Base(path)
content := ""
f, err := os.Open(path)
if err != nil {
}
f, _ := os.Open(path)
defer f.Close()
switch strings.ToLower(filepath.Ext(path)) {
case ".are":
Expand Down Expand Up @@ -120,12 +118,12 @@ func GetFileContents(path string) (string, string) {
}
content = buf.String()
default:
content, err = util.ReadFileToString(path)
content, err := util.ReadFileToString(path)
if err != nil {
return content, dir
}
}
return content, dir
return &content, dir
}

func (f fileview) Init() tea.Cmd {
Expand All @@ -143,13 +141,13 @@ func (f fileview) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return f, f.Init()
case SelectedFilePath:
content, title := GetFileContents(string(msg))
f.content = content
f.content = *content
f.viewport.SetContent(f.content)
f.title = title
return f, f.Init()
case PathMsg:
content, title := GetFileContents(string(msg))
f.content = content
f.content = *content
f.viewport.SetContent(f.content)
f.title = title
return f, f.Init()
Expand Down
14 changes: 10 additions & 4 deletions cmd/initial.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func InitialModel() initial {
item{title: "Discover", desc: "Find all strings in a mod/directory"},
item{title: "Traverse", desc: "Show tree of locations through a mod"},
item{title: "View", desc: "View any Infinity Engine file or text file"},
item{title: "Dialogue Tree", desc: "View the Dialogue tree of a mod"},
// TODO: Implement these
// item{title: "Add", desc: "Add strings to tra"},
// item{title: "Range", desc: "What range of numbers are free"},
Expand Down Expand Up @@ -69,29 +70,34 @@ func (i initial) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
switch i.list.SelectedItem().FilterValue() {
case "Check":
d := NewDirectoryPicker(true, "Select a Mod Directory")
d := NewDirectoryPicker(true, "Select a Mod Directory to start")
c := NewCheck()
f := NewFileView()
state.SetNextCommand(d).SetNextCommand(c).SetNextCommand(f)
return state.SetAndGetNextCommand(i), SendSelectedFile(current_path)
case "Discover":
d := NewDirectoryPicker(true, "Select a Mod Directory")
d := NewDirectoryPicker(true, "Select a Mod Directory to start")
l := NewList()
f := NewFileView()
state.SetNextCommand(d).SetNextCommand(l).SetNextCommand(f)
return state.SetAndGetNextCommand(i), SendSelectedFile(current_path)
case "Traverse":
d := NewDirectoryPicker(true, "Select a Mod Directory")
d := NewDirectoryPicker(true, "Select a Mod Directory to start")
f := NewDirectoryPicker(false, "Select an area to start")
t := NewTree()
v := NewFileView()
state.SetNextCommand(d).SetNextCommand(f).SetNextCommand(t).SetNextCommand(v)
return state.SetAndGetNextCommand(i), SendSelectedFile(current_path)
case "View":
d := NewDirectoryPicker(false, "Select a file to start")
d := NewDirectoryPicker(false, "Select a Mod Directory to start")
v := NewFileView()
state.SetNextCommand(d).SetNextCommand(v)
return state.SetAndGetNextCommand(i), SendSelectedFile(current_path)
case "Dialogue Tree":
d := NewDirectoryPicker(true, "Select a Mod Directory to start")
t := NewDialogueTree()
state.SetNextCommand(d).SetNextCommand(t)
return state.SetAndGetNextCommand(i), SendSelectedFile(current_path)
}
}
}
Expand Down
15 changes: 2 additions & 13 deletions cmd/list-varriables.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/charmbracelet/bubbles/table"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/dark0dave/infinity_dialog/pkg/components"
"github.com/dark0dave/infinity_dialog/pkg/translation"
"github.com/dark0dave/infinity_dialog/pkg/util"
)
Expand Down Expand Up @@ -97,19 +98,7 @@ func (l listVariables) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
h1, w1 := baseStyle.GetFrameSize()
h += h1
w += w1
if msg.Height > h {
l.table.SetHeight(msg.Height - h)
}
if msg.Width > w {
ratio := float64(msg.Width - w)
l.table.SetColumns([]table.Column{
{Title: "FileName", Width: int(0.2 * ratio)},
{Title: "Lang", Width: int(0.1 * ratio)},
{Title: "Id", Width: int(0.05 * ratio)},
{Title: "Value", Width: int(0.55 * ratio)},
})
l.table.SetWidth(int(ratio))
}
components.DynamicalSetTableSize(&l.table, &msg, h, w)
case tea.KeyMsg:
switch msg.String() {
case "q", "esc":
Expand Down
3 changes: 1 addition & 2 deletions cmd/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,12 @@ func findChildren(path string, file_map *map[string]string, nodes *[]tree.Node,
return nil
}
contents, err := util.ReadFileToString(path)
contents = strings.ToLower(contents)
if err != nil {
return err
}
filename := filepath.Base(path)
for k, v := range *file_map {
if k != filename && strings.Contains(contents, "\""+k[:len(k)-4]+"\")") {
if k != filename && strings.Contains(strings.ToLower(*contents), "\""+k[:len(k)-4]+"\")") {
child.Children = append(child.Children, tree.Node{
Value: k,
Desc: v,
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module github.com/dark0dave/infinity_dialog

go 1.23
go 1.23.0

require (
github.com/charmbracelet/bubbles v0.20.0
github.com/charmbracelet/bubbletea v1.2.4
github.com/charmbracelet/bubbletea v1.3.4
github.com/charmbracelet/lipgloss v1.0.0
github.com/dark0dave/infinity_file_formats v0.0.0-20241205000111-f0cefbb38b7d
github.com/dark0dave/infinity_file_formats v0.0.0-20250208171459-bfc2e8c1d507
github.com/savannahostrowski/tree-bubble v0.0.0-20230724043728-d7bb06a8a67e
golang.org/x/text v0.21.0
golang.org/x/text v0.23.0
)

require (
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/x/ansi v0.5.2 // indirect
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
Expand All @@ -25,10 +25,10 @@ require (
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sahilm/fuzzy v0.1.1 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.31.0 // indirect
)
Loading