Code Monkey home page Code Monkey logo

ktpapergui's Introduction

🌱 20 y/o, attending university full time studying software engineering.

Contact me :

Discord Presence

Instagram Badge

ktpapergui's People

Contributors

matt-mx avatar xyzaurora avatar zeonight avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ktpapergui's Issues

Signals

Instead of having a SignalButton class it's probably better to have an effect block that we use our signals inside, allowing the signals system to support anything that extends GuiButton.

Declarative Command processing

Rewrite how arguments and sub-commands are decided by trying each argument to get it's value at it's expected position.

We need to support #25 by allowing for options and flags at the end of the process.

Redesign GuiScreens

Get rid of useless item pointer hashmap and just use one hashmap for slot to button.

Dynamic Conversations

Allow for conversations to be dynamically changed while it's running.
For example

conversation(stuff) {
	stringPrompt("stuff") { c, s ->
		if (s == "hello") {
			stringPrompt("name") { c1, s1 ->
				println("Hello $s1")
			}.update(player)
		}
	}
}.build(player).begin()

This would allow for more complex conversations.

This could be accomplished by keeping track of the conversation prompts, and if we need to change it then we can cancel the current conversation and rebuild the conversation only including the most recent prompt.

Declarative command parameter type

The sender type param should be moved into the runs function, allowing for a fresher look of the DSL, as well as different executions for different sender types if wanted.

Currently

("foo" /
    listOf(
        ("fizz" / someArg)<CommandSender> {
            runs { reply(!someArg()) }
        },
        ("bar" / someArg)<CommandSender> {
            runs { reply(!someArg()) }
        }
    )
)<CommandSender> {
    runs { reply(!"Foo") }
}

Proposed Change

("foo" /
    listOf(
        ("fizz" / someArg) {
            runs<Player> { reply(!"&cHi player: &r${someArg()}") }
            runs<CommandSender> { reply(!someArg()) }
        },
        ("bar" / someArg) {
            runs<CommandSender> { reply(!someArg()) }
        }
    )
) {
    runs<CommandSender> { reply(!"Foo") }
}

Task Builder

Allow tasks to be chained together.
Currently to have an sync run after a sync we must do

async {
   // code
    sync {
    
    }
}

We can implement a chain builder such as

    async {

    } thenSync {

    }

    asyncDelayed(20) {

    } thenSync {

    }

    asyncRepeat(20) {

    } thenSync {
        // Runs once above is cancelled
    }```

Rewrite Conversation api

A rewrite of the conversation wrapper would be useful to remove boilerplate.

Also would there be a way to introduce tab completion suggestions alongside this?

conversation {
  exitOn = "cancel"
  
  // called if player types "cancel"
  exit {
    println("exit")
  }

  // called when conversation begins
  start {
    player.closeGui()
  }

  // gets a raw string input
  getString {
    runs {
      println(result)
    }
  }

  // gets a string that matches the regex provided
  getRegExp {
    regex = "[A-Z0-9_]{3-16}".toRegex()
    runs {
      println(result)
    }

    // runs if the input is invalid
    invalid {
      println("$result is not valid")
    }
  }

  // gets an integer within a given range
  getInteger {
    range = (1..30)
    runs {
      println(result * 2)
    }
  }

}.begin(player)

Option & Flag arguments

Declarative commands should have a flag/option argument type introduced.

Example implementation

val player by username()
val after by optionArgument<Date>()
val order by optionArgument<OrderByEnum>()
val boolean_option by flag()

("history" / player) {
    + after // Register the after argument
    + order // Alternatively call .withKeyValue(order) for java

    runs<CommandSender> {
        val records = Database.queryHistory(player)
            .recordsAfterDate(after())
            .orderBy(order())
            .get()
            
        if (records.isEmpty)
            return@runs reply(!"&cThat user has no records.")
            
        for (record in records) {
            reply(!record)
        }
    }
} register this

This example command would be invoked like this:

/history MattMX --after 13/06/2024 --order date_asc --boolean-option

The argument type's format should be relatively customizable.

/history MattMX -after:13/06/2024 -order:date_asc -boolean-option

Incompatibility with Java

I was trying to implement a GUI toggle button on java, however I get this issue:
imagem

Cannot access kotlin.jvm.functions.Function1

Since the readme describes compatibility with Java, I assume this is an unwanted side effect.

inappropriate men

there is too many big oiled men on this repo. can we sort that out? thyansks
ben muhteşemim

String command dsl

Implementing a new DSL for command building could be useful.

"/test <player:player> <msg:string...>" {
	val player by argument<Player>()
	val msg by argument<Array<String>>()
	
	player.sendMessage(!"&7[${source.name} -> Me]" + Component.text(msg))
	source.sendMessage(!"&7[Me -> ${player.name}]" + Component.text(msg))
}

"/foo" {
	"bar" {
		source.sendMessage("Bar")
	}
	"fizz <msg:string...>" {
		val msg by argument<Array<String>>()
		source.sendMessage("Fizz ($msg)")
	} missing {
		source.sendMessage("Argument $argName is required")
	}
}

Item editing on the fly

Items should be able to be edited on the fly, such as in an InventoryClicked event.

Currently we have to change that item instance of the user who clicked but if we only want to change one thing then it's counter productive.

Sound builder

Ability to chain sounds together for more complex sound feedback.

Kotlin

val custom = soundBuilder {
  emitter(self)
  location { player.location.clone().add(0.0, 100.0, 0.0) } 

  play(someSoundKey) volume 1.0 pitch 2.0 relative true
  wait(1.tick)
  play(someOtherSoundKey) volume 2.0 pitch 0.0 emitter self
}

// ...
player.playSound(custom)

Java

SoundBuilder custom = new SoundBuilder()
  .play(Sound.of(someSoundKey).volume(1.0).pitch(2.0).relative())
  .wait(1L)
  .play(Sound.of(someOtherSoundKey).volue(2.0).pitch(0.0).relative());

// ...
custom.playSound(player);

Better java support

Currently KtGui supports Java through Kotlin's native compatibility, but I've made no effort to actually add better Java useability.

Implementing Builder functions that we can chain, where Kotlin would have code blocks, could help.

GuiScreen gui = new GuiScreen(Component.text("Title"), 3)
	.addChild(
		new GuiButton<>(Material.DIRT)
			.named(Component.text("Item")
			.click(ClickType.LEFT, (event) -> event.getPlayer().sendMessage(Component.text("clicked!")))
			.lore(Component.text("Lore line one"))
			.lore(Component.text("Lore line two"))
			.slot(3)
	).addChild(...);

// Will need to add compat for signals, not as pretty as kotlin.
Signal<String> signalExample = gui.createSignal<String>("mattmx");

gui.effect(signalExample, () -> {
	new GuiButton<>(Material.DIAMOND)
		.named(Component.text(signalExample.get()))
		.slot(5)
		.childOf(gui);
});

gui.open((event) -> event.getPlayer().sendMessage(Component.text("opened.")));

gui.open(player);

Scoreboard Numbers

Numbers are currently inversed on the scoreboard. This looks quite ugly.
Fix this by inverting the scores.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.