Skip to main content

News

Topic: The Sphere Studio v1.2.1 (Read 168178 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Radnen's Sphere Studio v1.2.1
Reply #555

It would be nice to take a leaf from MSVC and modern browsers and implement a mini search bar that pops up at the top of the script view when you press Ctrl+F and highlights text as you type.


Yes, I was wanting to do this for some time. If this is the time to do it, the please be my guest. :)

Oh, BTW I'm adding a new feature, the master palette. It's attached to the ImageEditControl, what it does is shows you the palette used by the whole image. If you change a color there, it changes every pixel automatically. It's useful for map editing when you want to edit multiple tiles pixel colors all at once than painstakingly selecting them one at a time.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Radnen's Sphere Studio v1.2.1
Reply #556
That's a neat idea.  That was one great convenience we lost in the transition from 256-color to truecolor displays: The ability to change colors quickly at a high-level using palette manipulation.  I remember that fondly from my QB 4.5/mode 13 days. :)  Nowadays if you want to do something similar to that in realtime you can get the effect using shaders, but for a long time it just wasn't possible.

Since Sphere tiles and sprites are actually truecolor I assume it'll be implemented via search-and-replace on the pixels themselves?
Sphere 5.5.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Radnen's Sphere Studio v1.2.1
Reply #557

I assume it'll be implemented via search-and-replace on the pixels themselves?


Yep. I'm leveraging the ReplaceColor feature I already have in the image edit control. Since it affects the image edit control, for maps you must select all of the tiles before you can use the new feature. I didn't feel like creating a special version for sprites, tiles and images, so I just created the one for the image editor. It's still very easy to use and is enabled everywhere the image editor is.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • N E O
  • [*][*][*][*][*]
  • Administrator
  • Senior Administrator
Re: Radnen's Sphere Studio v1.2.1
Reply #558

Oh, BTW I'm adding a new feature, the master palette. It's attached to the ImageEditControl, what it does is shows you the palette used by the whole image. If you change a color there, it changes every pixel automatically. It's useful for map editing when you want to edit multiple tiles pixel colors all at once than painstakingly selecting them one at a time.


OMG I've wanted this in the editor for over a decade and hated having to select multiple tiles to edit many at once to do the color replacement. I was too lazy to figure out the map editor myself to add it, so good stuff dude!

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Radnen's Sphere Studio v1.2.1
Reply #559
The new search bar is coming along nicely.  Still has a couple bugs in it, but it mostly works as designed.  See screenshot attached.
Sphere 5.5.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Radnen's Sphere Studio v1.2.1
Reply #560
Nice job!

I haven't tried it out, so this is just a list to make sure the UX is decent:

1. Make it so that when you select a word and hit Ctrl+F, it pre-populates the dialog like in Visual Studio.
2. And make it so that when you do that with Ctrl+F, hitting Ctrl+H turns it into the Search & Replace without losing the settings.
3. Then if the dialog is popped up and you hit enter, either search or search & replace the text in the text boxes. This is about focus, we shouldn't have to click on the box when we hit Ctrl +F to search and replace your brain is in "search and replace mode".

With those 3 things working, the search and replace will feel like it's not there. ;)

As for the palette selector, I have finished it. The hardest part is ordering the colors correctly. Right now I'm just ordering by Hue. But there always seem to be outliers in the sort. That's because 3 components make up a color: HSL or RGB. But by ordering by lightness curves, etc. it is still not perfect. In fact I have found no good algorithm for this. A very few solutions online are quite accurate, but still they only get it right about 90% of the time. But for our human eye, we know how to sort colors, a problem devilishly complex for a computer to solve.

Do you guys care about perfectly sorted colors?

Anyways, that said, following the MVC approach on the component (separation of concerns and what-not) meant that the colors update automatically, you get undo/redo, and no extra code was needed to bridge the gap between the component and the replace color functionality of the editing control. All in all, it was a very easy and sweet integration and I'm sure the artists of this community will absolutely love it. I'll have it ready much later today when I return home from work.
  • Last Edit: March 22, 2016, 11:39:08 am by Radnen
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

Re: Radnen's Sphere Studio v1.2.1
Reply #561

As for the palette selector, I have finished it. The hardest part is ordering the colors correctly. Right now I'm just ordering by Hue. But there always seem to be outliers in the sort. That's because 3 components make up a color: HSL or RGB. But by ordering by lightness curves, etc. it is still not perfect. In fact I have found no good algorithm for this. A very few solutions online are quite accurate, but still they only get it right about 90% of the time. But for our human eye, we know how to sort colors, a problem devilishly complex for a computer to solve.

Do you guys care about perfectly sorted colors?

Maybe make it possible to rearrange the colors after they've been roughly sorted?

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Radnen's Sphere Studio v1.2.1
Reply #562

Nice job!

I haven't tried it out, so this is just a list to make sure the UX is decent:

1. Make it so that when you select a word and hit Ctrl+F, it pre-populates the dialog like in Visual Studio.
2. And make it so that when you do that with Ctrl+F, hitting Ctrl+H turns it into the Search & Replace without losing the settings.
3. Then if the dialog is popped up and you hit enter, either search or search & replace the text in the text boxes. This is about focus, we shouldn't have to click on the box when we hit Ctrl +F to search and replace your brain is in "search and replace mode".

With those 3 things working, the search and replace will feel like it's not there. ;)


I merged my changes into master.  Since your change is to an unrelated component (image editor), there shouldn't be any conflicts.

All your points above should be covered.  I went to great pains to make it behave exactly like MSVC's search box, which involved a lot of screwing around and trying different things (basically the same method I used to make minisphere compatible with Sphere 1.x -- brute-force reverse engineering :P)

WinForm's handling of focus doesn't exactly align with the UI goals of this type of component, so parts of the code may be hard to follow.  So I added a paragraph to the top of the search box code explaining the intended behavior:
https://github.com/Radnen/spherestudio/blob/master/ScriptEditPlugin/Components/SearchBox.cs#L21-L37
Sphere 5.5.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Radnen's Sphere Studio v1.2.1
Reply #563
One thing I'd like to see in the future is file system monitoring in the script plugin so that, if a script file changes outside the IDE, it's automatically reloaded, or prompts to do so if there are unsaved changes.  This is one thing that comes in handy in MSVC when working with version control.  I often find myself reverting changes through the GitHub client after I screw something up, and it's annoying to have to close the file and reopen it.  And then if you forget to do that, you end up un-reverting the reverted changes. :P
  • Last Edit: March 22, 2016, 01:46:53 pm by Lord English
Sphere 5.5.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Radnen's Sphere Studio v1.2.1
Reply #564

All your points above should be covered.  I went to great pains to make it behave exactly like MSVC's search box, which involved a lot of screwing around and trying different things (basically the same method I used to make minisphere compatible with Sphere 1.x -- brute-force reverse engineering :P)


Sweet, that's exactly it. :)

@HopeMetal: That's nice if we get to save the colors boxes and keep them consistent. Unfortunately, for now it's auto-generated each time colors are changed on the source image. I think I'll just keep them sorted by Hue for now and iterate on this concept once I've released it.

I realized just now, I'm not handling alpha values at all. I had plans and some older code outlining a custom color selector. I might just have to go and complete it and add that in.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Radnen's Sphere Studio v1.2.1
Reply #565
Ok, I'm delaying the release of the master color palette editor. I'm going to add some useful features to it, like copy swaths of colors, and an eyedropper to find specific colors from the target image. These two will make it far, far more usable than it is now.

For example, if you select 4 colors of a bush and change them, then you've only changed it for that bush. If there is another bush and you want to copy the palette over to that one, you can't. So I'm going to add the ability to copy ranges of colors. The eyedropper is useful for discerning between two colors that look similar, but are different (if you know where to look on the source image, use the eyedropper, and then continue on like normal).

BTW, I separated the colors channels into distinct red, green, blue, and greyscale groups, sorted them, and then stitched it back together. I got a much cleaner looking result.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Radnen's Sphere Studio v1.2.1
Reply #566
Have you tried the new search bar?  I think I finally got all the bugs out of it. :)
Sphere 5.5.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Radnen's Sphere Studio v1.2.1
Reply #567
On a sidenote, recent MSVC versions must have some kind of crazy awesome parser... you can put the cursor on a variable or function name, and not only will it highlight all occurrences of it, but it shows ONLY real matches, i.e. it respects scope, whether it's a variable or function, etc.  It's incredibly useful, and just another thing that makes MSVC one of the best IDEs ever made, despite its bloatedness.  If only the same could be said for its C++ compiler...

That highlighting feature is something I would love to see in Sphere Studio someday, but alas, Scintilla isn't quite that powerful.
Sphere 5.5.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub

  • Radnen
  • [*][*][*][*][*]
  • Senior Staff
  • Wise Warrior
Re: Radnen's Sphere Studio v1.2.1
Reply #568

That highlighting feature is something I would love to see in Sphere Studio someday, but alas, Scintilla isn't quite that powerful.


Hmm, I figured the syntax highlighting would be tied directly to the language parser. We'd have to use ANTLR or some library like it to create our own parser, and then highlight pieces of an AST on demand. It's doable, but not easy nor quick to achieve.

I pulled the code and tried it out. It works very well! :) But I still got it to a state where hitting ESC didn't close it. And then I assume the style will come later, because right now it looks a bit bland. Also integration with the currently selected theme would be nice to have as well. But all in all, it serves it's basic use and the regex search is just as good as any so I'm happy.

Then a future bonus would be to search current file, opened files, and all files. But that may need more of a backend change, perhaps when we add the feature to detect changes from the filesystem. That said, the project list knows, I think what we need is a dedicated link between an item on the project list and the opened document. My first version of this editor had that, I was able to (as a demonstration) highlight the file that was opened as well as handle file renaming. I'm pretty sure once we do that, the rest ought to be easier to manage.
If you use code to help you code you can use less code to code. Also, I have approximate knowledge of many things.

Sphere-sfml here
Sphere Studio editor here

  • Fat Cerberus
  • [*][*][*][*][*]
  • Global Moderator
  • Sphere Developer
Re: Radnen's Sphere Studio v1.2.1
Reply #569
The thing is that Scintilla uses a generic "C++" parser to handle all languages with a C-like grammar, including JavaScript.  Semantics and scope handling vary between languages so I guess it's not possible with the stock functionality.  Oh well, something to add to the wishlist.

The ESC bug was actually fixed in my working copy, but I never made a commit for it.  It's fixed in master now.  Let me just say that WinForms keyboard handling is not one of its strong suits, it took me a while to figure out the right way to handle hotkeys and such!  But I agree that it's bland-looking.  I'll work on sprucing it up a bit in my spare time, I just wanted to get it functional since not having a search feature was a major blocker for the Scintilla upgrade, and it served as a perfect excuse to implement QuickFind. :D

As for Find in Files, yes, that was the next thing I wanted to tackle, but it's a tricky thing--you only want to look at code files, and with the plugin system abstracting all the file types and such away, it's a bit more difficult than when the editor was completely monolithic.
Sphere 5.5.2 - neoSphere engine - Cell compiler - SSj debugger
forum thread | on GitHub