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

OutputTextRaw overrides custom style settings on command bar #1345

Open
KVonGit opened this issue Jan 1, 2025 · 0 comments
Open

OutputTextRaw overrides custom style settings on command bar #1345

KVonGit opened this issue Jan 1, 2025 · 0 comments

Comments

@KVonGit
Copy link
Collaborator

KVonGit commented Jan 1, 2025

Discussion in Quest channel on Discord: https://discord.com/channels/1278365322054996018/1314620834467545200/1324154058612674664

Angel's suggestions:

  <function name="OutputTextRaw" parameters="text">
    <![CDATA[
    format = GetCurrentTextFormat("")
    JS.addText("<span style=\"" + format + "\">" + text + "</span><br/>")
    ResetCommandBarFormat
    RequestSpeak (text)
    ]]>
  </function>

  <function name="ResetCommandBarFormat">
    format = GetCommandBarFormat()
    if (GetString(game, "commandbarformat") <> format) {
      game.commandbarformat = format
      JS.setCommandBarStyle(format)
    }
  </function>

  <function name="GetCommandBarFormat" type="string">
    format = GetCurrentTextFormat("") + ";background:" + game.defaultbackground
    if(HasString(game, "overridecommandbarformat")) {
      format = format + ";" + game.overridecommandbarformat
    }
    return (format)
  </function>

and to make sure it doesn't mess with hiding:

function setCommandBarStyle(style) {
    var width = $("#txtCommand").width();
    var hidden = $("#txtCommand").is(":hidden") && $("#txtCommand").parent().is(":visible");
    $("#txtCommand").attr("style", style);
    $("#txtCommand").width(width);
    if(hidden) {
        $("#txtCommand").hide();
    } else {
        $("#txtCommand").show();
    }
}

I think it's a bit overkill; but the combination least likely to cause gotchas for anyone who's already overridden one or more of those functions.

Note: While I was writing those functions, I created an attribute game.overridecommandbarformat - if that code gets used it would probably be advisable to add this to the editor too, so users can just type some CSS in a box if they want the command bar to use a different font from the main text or something. And also to add the attribute to the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant