Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nice in-game support for scenario creation/editing #558

Open
byorgey opened this issue Jul 14, 2022 · 10 comments
Open

Nice in-game support for scenario creation/editing #558

byorgey opened this issue Jul 14, 2022 · 10 comments
Assignees
Labels
C-Project A larger project, more suitable for experienced contributors. G-Scenarios An issue having to do with scenario design, the way scenarios are described and loaded, etc. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. T-Map editor Tooling for editing scenario maps T-UI Involves the user interface. Z-Feature A new feature to be added to the game.

Comments

@byorgey
Copy link
Member

byorgey commented Jul 14, 2022

It would be super cool to have an in-game graphical scenario editor, where you could move a cursor around, draw terrain and entities, place robots, create custom entities and code, etc...

Of course the scenarios would still be stored in .yaml files, so creating them by hand will always be an option.

This would obviously be a massive undertaking, and I don't think it needs to happen any time soon, but I just thought of it today so writing it down!

@byorgey byorgey added Z-Feature A new feature to be added to the game. C-Project A larger project, more suitable for experienced contributors. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. T-UI Involves the user interface. G-Scenarios An issue having to do with scenario design, the way scenarios are described and loaded, etc. labels Jul 14, 2022
@xsebek
Copy link
Member

xsebek commented Jul 15, 2022

Selecting a cell with right click and then drawing by holding left mouse button would be pretty sweet. 🎨

@xsebek
Copy link
Member

xsebek commented Jul 15, 2022

For inspiration, asciiflow has a simple editor with some line drawing logic that could be useful for mazes.

@byorgey
Copy link
Member Author

byorgey commented Oct 9, 2022

Wait, I just had an epiphany --- we don't need to make a scenario editor, because you should be able to just program your own! A few ingredients would go into this:

  • Input handler command #102 would let you move a robot around with arrow keys, program your own hotkeys for placing certain items, drawing certain structures, etc., and of course you could always just write programs to create and place whatever entities you want
  • We should add a built-in scenario that starts with a blank world in creative mode
  • There needs to be a way to save the current world in the format expected by a scenario description (related to Saving and loading games #50).

@byorgey byorgey changed the title Scenario editor Nice in-game support for scenario creation/editing Oct 9, 2022
@byorgey
Copy link
Member Author

byorgey commented Oct 9, 2022

Well, OK, being able to draw stuff with the mouse would still be pretty cool, too. But maybe we can think of an in-game way to do that---like some device that lets you receive mouse events and respond to them somehow, similar to #102 . If we also had the ability to teleport entities in creative mode, you could then write a little program that responds to mouse events by teleporting certain entities to the proper coordinates.

@byorgey
Copy link
Member Author

byorgey commented Oct 9, 2022

The overarching principle here is that this is a programming game --- instead of building in more and more cool features into the game itself, we should just build in programming language features that let players build the cool game features they want. (It even already says this in DESIGN.md, believe it or not. 😄 )

@xsebek
Copy link
Member

xsebek commented Oct 9, 2022

That is quite mind blowing and I love it! 🤯 Making mouse events an upgrade sounds good to me, I guess you just get coordinates and a boolean. 🤔

Making saves compatible with scenarios would be great and this interactive workflow could really save time.

@byorgey
Copy link
Member Author

byorgey commented Oct 9, 2022

Making mouse events an upgrade sounds good to me, I guess you just get coordinates and a boolean.

I guess it depends how sophisticated you want to be. Many real GUI frameworks differentiate between more than two kinds of mouse events, e.g. mouse down, mouse up, mouse move, etc. I mean, I guess we should just see what mouse events are provided by brick and just pass those along.

@xsebek
Copy link
Member

xsebek commented Oct 9, 2022

We still might need a form to set some parts of the game like the world function. After you are done with the scenario you would probably want to e.g. reset time, add win conditions and description.

@byorgey
Copy link
Member Author

byorgey commented Oct 9, 2022

Yes, that's very true. And maybe it's worth building some of that into the app so that you can create a scenario without directly editing a .yaml file. But at least we don't need to build an actual graphical world editor.

@kostmo kostmo self-assigned this Nov 20, 2022
kostmo added a commit that referenced this issue Dec 20, 2022
Towards #558

This is another no-op refactor to shrink the size of #873
mergify bot pushed a commit that referenced this issue Dec 20, 2022
Towards #558

Also, move the following functions to `Util` module:
* `setFocus`
* `openModal`
* `isRunningModal`

This is another no-op refactor to shrink the size of #873.
mergify bot pushed a commit that referenced this issue Jun 9, 2023
Towards #558
I was motivated to build this after finding that editing scenario maps directly in the YAML file is rather constraining.

## What I've implemented so far
* A small, collapsible panel to the left of the REPL containing World Editing status/operations.  Enter world-editing mode with CTRL+e to show the panel.
    * This works only in `--cheat` mode
* Terrain selection
    * A "picker"/"eye dropper" middle-click mechanism to select a terrain style to draw.
    * A pop-up selector to choose between the 5 different types of terrain.
* Drawing terrain with the left mouse button
* Saving a rectangular section of the world map (terrain only) to a file with CTRL+s
* Code organization
    * The complete state of the World Editor, including "painted overlays" of terrain, is contained within the `uiWorldEditor` field of `UIState` record.
    * The bulk of the World Editor functionality shall be in new modules
    * Some refactoring of `Controller.hs` and `View.hs` to extract functions utilized by the World Editor (towards #707)

## Vision

* The audience for this tooling is strictly envisioned to be Scenario authors.
    * Though, if we eventually allow swarm-lang to program the UI, there may be some common code to extract.
* The World Editor is intended to be compatible with a workflow of editing maps in text form within YAML scenario files.

# Demos
## Round-trip with random world

    stack run -- --scenario creative --seed 0 --cheat

Then Ctrl+e, tab down to the Save button, hit Enter to save the map
In another tab run:

    stack run -- --scenario mymap.yaml

Toggle between tabs to compare, observe the derived map is an identical 41x21 subset.
@byorgey byorgey added the T-Map editor Tooling for editing scenario maps label Aug 19, 2023
@byorgey
Copy link
Member Author

byorgey commented Jun 21, 2024

Note, we do now have a prototype in-game editor, though it's still somewhat limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Project A larger project, more suitable for experienced contributors. G-Scenarios An issue having to do with scenario design, the way scenarios are described and loaded, etc. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. T-Map editor Tooling for editing scenario maps T-UI Involves the user interface. Z-Feature A new feature to be added to the game.
Projects
None yet
Development

No branches or pull requests

3 participants