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

Prompt does not support color codes in web client #973

Closed
FlutterSprite opened this issue May 6, 2016 · 16 comments
Closed

Prompt does not support color codes in web client #973

FlutterSprite opened this issue May 6, 2016 · 16 comments
Labels
bug An actual error or unwanted behavior. more info needed Can't continue resolving without more info.

Comments

@FlutterSprite
Copy link
Contributor

prompt_colors

Brief summary of issue / Description of requested feature:

The prompt in the webclient doesn't currently support the same color codes as the rest of the client output. I modified my prompt function to both update the prompt as well as message the prompt's string to the character - above is how the prompt should appear, and below is how it does. This isn't an issue with my CSS file, as the issue persists even if I use the stock CSS file or no CSS file at all.

Steps to reproduce the issue / Reasons for adding feature:

  1. Send a message with the "prompt=" parameter with color codes in the string.
  2. The color codes are printed as text - the expected output is to have them show in color.

Expected result of feature

The prompt should display with color codes! Lots of games use color codes in their prompts - in fact, I would wager that every game with color support does.

@FlutterSprite FlutterSprite changed the title Prompt does not support color codes Prompt does not support color codes in web client May 6, 2016
@Griatch Griatch added bug An actual error or unwanted behavior. devel labels May 21, 2016
@Griatch
Copy link
Member

Griatch commented May 21, 2016

I presume this is in devel branch.

@Griatch
Copy link
Member

Griatch commented May 21, 2016

This seems to work correctly in devel branch. Closing this now. Request a re-open if you are still having issues.

@Griatch Griatch closed this as completed May 21, 2016
@FlutterSprite
Copy link
Contributor Author

I just did a pull of the wclient branch to update everything as of this morning - refreshed, cleared my cache, the works - and I'm afraid I'm still getting the issue. I did modify my CSS file a bit - would that have any effect on this at all? I assume not, since I don't think stripping out the color codes has anything to do with the CSS file...

Also, sorry if I'm coming off as naggy or unhelpful! I just read back over this again and realized it comes across as really whiny, ehehe

@Griatch
Copy link
Member

Griatch commented May 22, 2016

@BattleJenkins

I tested with the example from your prompt and in the wclient-branch web client I get the following result:

issue973_prompt_colors

For easier copy&pasting (images suck for this), here's the command I tried:

@py self.msg(prompt=("|555|[030HP: 12/12 |[011  |255SP: |45512 |255/|455 12|n"))

Which, apart from too many spaces here and there seems to work as expected. The CSS is critical for the colors though - we are after all looking at a html file being built dynamically. A large portion of the webclient CSS file is dedicated to how Xterm256 colors are to be displayed (512 lines of it, in fact). But if you have xterm256 working elsewhere in the client you should have the correct webclient.css file at least.

Reopening this, but can still not reproduce the problem. Can you give some example of a prompt that doesn't work?

@Griatch Griatch reopened this May 22, 2016
@Griatch Griatch added the more info needed Can't continue resolving without more info. label May 22, 2016
@FlutterSprite
Copy link
Contributor Author

Here, I tried the exact line of code you provided, but it didn't seem to work!

So, the problem is likely from my end somewhere... I haven't touched the webclient aside from providing my own CSS file, so I'm going to try going with the default and seeing if that's what's causing the issue, and get right back to you!

@FlutterSprite
Copy link
Contributor Author

Okay so I dummied out my custom CSS file in the static_overrides and it reverted to the default CSS file. Unfortunately, I still seem to be getting the issue.

Here's my normal prompt update code, just in case it helps, but since updating the prompt manually with the @py command doesn't seem to fix it, I'm not sure if it would:

def prompt_update(character):
    "Updates the given character's prompt. Called at the end of every command or when the character takes/heals damage."
    if not rules.is_fighter(character):
        return
    hbar = health_bar(character.db.HP, max(character.db.VIT * 3, 1), 20)
    action = ""
    moves = ""
    sptotal = "|255SP: |455%i |255/|455 %i|n" % (character.db.SP, character.db.SPE * 2)
    engaged = False
    # Checks to see if there are any fighters engaged with character:
    if character.db.Combat_TurnHandler and character.db.Combat_Range and character.db.Combat_TurnHandler.db.fighters:
        for fighter in character.db.Combat_TurnHandler.db.fighters:
            if fighter != character and character.db.Combat_Range[fighter] == 0:
                engaged = True
    if character.db.Combat_Actions:
        action = "|525[Action Ready]|n "
        if engaged:
        # Colors the 'Action Ready' text red if engaged with anyone.
            action = "|522[Action Ready]|n "
    if character.db.Combat_Moves:
        moves = "|552[Moves: |554%i|552]|n" % character.db.Combat_Moves
    if character.db.Combat_Second:
        action = "|255[Second Attack Ready] |n"
    promptline = ("%s: %s %s %s%s" % (str(character), hbar, sptotal, action, moves))
    character.msg(prompt=promptline)

@Griatch
Copy link
Member

Griatch commented May 22, 2016

@BattleJenkins

Hm. I just tested it with both Firefox and Chrome and the colors seems to be working in both places for me. Have you tried different browsers? Since I presume you have xterm256 colors working in the web client outside the prompt, it should not be a problem with the CSS file, really (and you are using the latest CSS anyway if you copied it manually).

Just to weed out the simple errors, I presume you are shutting down both the Portal and Server, right? HTML color conversion is happening at the Portal level, so you can't just @reload to update it.

Secondly, let's make sure your client is really pulling the latest, stop your server/portal completely, then go to mygame/web and delete the "static" folder. This folder is created automatically (it should never contain any manual changes, those go in the static_override folder) so when you start again, this folder will be automatically rebuilt (you'll see a lot of copy-lines). See if that helps.

@FlutterSprite
Copy link
Contributor Author

I've only tried it in Chrome so far - I don't have any other browsers installed currently, because I'm a bad developer.

I stopped the server completely with 'evennia stop' on the command line, deleted the entire static folder, started it up again, saw all the copy-lines, and... same problem. Tried clearing the cache, using an incognito window, everything, but I'm still getting the same dang problem...

@Griatch
Copy link
Member

Griatch commented May 22, 2016

Since I can't reproduce this with a fresh Evennia, it's hard to really tell what the problem is.

To completely make sure you can --init a new temporary game folder (off the wclient branch code), start it up and run the command there, does it work then?

@FlutterSprite
Copy link
Contributor Author

Completely fresh install and... what the dang heck.

Maybe there's something wrong with my evennia code somehow - I've been on the wclient branch with no problems before this...

@Griatch
Copy link
Member

Griatch commented May 22, 2016

Ok, so I cloned the latest Evennia off github, installed a new virtualenv, did the whole install from scratch, switched to wclient branch and initialized a game dir, migrated and started the server. I have a colored prompt just fine, both in Chrome and in Firefox.

Could you try the full-out fresh reinstall too - then it really can't be any difference between our setups. In that case it more sounds like something fishy with your browser or something strange like that.

@FlutterSprite
Copy link
Contributor Author

Okay I absolutely completely started over in a whole new directory with a whole new virtualenv with a fresh install from github:

Whyyy!!

If it really is a browser issue - does it do this for you? I've got the server online if you want to check it: http://62.151.177.174/webclient/

@FlutterSprite
Copy link
Contributor Author

So I checked out the log and got something interesting:

2016-05-22T10:12:10+0000 [AMPProtocol,client] [::] Traceback (most recent call last):
2016-05-22T10:12:10+0000 [AMPProtocol,client] [::]   File "/home/new-evennia/evennia/evennia/server/portal/portalsessionhandler.py", line 378, in data_out
2016-05-22T10:12:10+0000 [AMPProtocol,client] [::]     getattr(session, funcname)(*cmdargs, **cmdkwargs)
2016-05-22T10:12:10+0000 [AMPProtocol,client] [::]   File "/home/new-evennia/evennia/evennia/server/portal/webclient_ajax.py", line 348, in send_text
2016-05-22T10:12:10+0000 [AMPProtocol,client] [::]     args[0] = parse_html(text, strip_ansi=nomarkup)
2016-05-22T10:12:10+0000 [AMPProtocol,client] [::] UnboundLocalError: local variable 'text' referenced before assignment
2016-05-22T10:12:10+0000 [stdout#info] ajax.send_default prompt ('|555|[030HP: 12/12 |[011  |255SP: |45512 |255/|455 12|n',) {'options': {}}'

@Griatch
Copy link
Member

Griatch commented May 22, 2016

Oh! You are using the AJAX client. That would explain why we get different results - if your ports are not correctly set for using the websocket, it will fall back to the AJAX, and a bug there may well linger. I'll look at that.

@FlutterSprite
Copy link
Contributor Author

Dang! I guess that explains it! It's a good thing I'm a total amateur at configuring server settings and ports and such so I could uncover this obscure bug!

@FlutterSprite
Copy link
Contributor Author

Now behaving as expected! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An actual error or unwanted behavior. more info needed Can't continue resolving without more info.
Projects
None yet
Development

No branches or pull requests

2 participants