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

Add: setConfig and getConfig functions #5452

Closed
wants to merge 10 commits into from
Closed

Add: setConfig and getConfig functions #5452

wants to merge 10 commits into from

Conversation

ktunkiewicz
Copy link
Contributor

@ktunkiewicz ktunkiewicz commented Sep 24, 2021

NOTE: Currently this is work-in-progress PR with only the setMudletConfig added - I want to see a feedback on this before I continue the work

Brief overview of PR changes/additions

  • new Lua function setMudletConfig(key, value) that allows changing various Mudlet settings
  • new Lua function getMudletConfig(key) that allows reading various Mudlet settings

Motivation for adding to Mudlet

People are lazy. They don't read on-screen instructions carefully and asking to read Readme on github repo of your scripts is usually a waste of time - I'm pretty sure a lot of script creators will tell you that :)

On the other hand, all games are different - they often originate from code made in 80's, and for each game you need a specific config values to be set to make the game work well.

All maps are different, but they usually have one thing in common - they look best with specific settings that the map creator uses. This is most important when there are images and symbols used on the map.

The proposed change is to allow setting various Mudlet settings that are important in these situations. Below is the list of settings it allows changing, and a brief explanation why I think this should be allowed to change from inside scripts.

NOTE: I selected only the settings I believe are safe to allowed being changed on behalf of the player that are game-specific and usually are not opinionated settings that each player sets to what they prefer.

NOTE 2: Please remember that a vast majority Mudlet users are not script makers nor map editors. They just want a nice game experience that someone else prepared for them. People who know how to edit scripts/maps will understand the fact that a script changed some settings because they know how this works, what these settings do, and how to modify scripts not to do this if it annoys them. So, please read the "explanations" I gave from a point of view of typical player.

Key Setting Explanation
mapperRoomSize The room size input field in mapper window panel When designing a map that uses symbols and images, they look and work the best with the size that the map creator is using. Player issues avoided: "Hey, I cannot see these map symbols", "That image you added in there is unreadable because rooms are covering it"
mapperExitSize The exit line size field in mapper window panel Added this just to play together with room size, motivation is similar.
mapperRoundRooms The round rooms checkbox in mapper window panel The same motivation as above
mapperShowRoomIds The room ids checkbox in mapper window panel If the map functionality uses symbols extensively, showing ids will hide the symbols, so it's useful to pre-set the mapper not do do this when your game GUI is starting
mapperShowMapInfo The dropdown-checkboxes for room info in the mapper panel If your scripts implement a custom map info, or simply your map is not done in a way that the short/full info panels provide useful information, it will look better if your scripts automatically enable your own info panel, or just remove all of the default ones
mapperHideMapInfo the same as above, just unchecking the checkbox
mapperShow3dView the 2D/3D switch in mapper panel If your map was made specifically for 3D view, you'll find it useful to automatically switch into that view
mapperPanelVisible for hiding/showing the settings panel in mapper You'll be surprised to know how many of the players I know didn't know they can hide that panel. And if you have a nice GIU with graphics and everything, that panel just looks ugly. It's nice to get it hidden, especially if you already preset everything in the mapper for your players
mapperShowRoomBorders the room borders checkbox in Mapper preferences Personally I find these borders ugly, and the map I prepared has its colours selected carefully to be readable and well visible without room borders. And that's where it looks really good. So as a map creator I'd like to switch these off for players
generalEnableGMCP the checkbox to enable GMCP in General preferences I got few reports from players that GMCP stopped working for them, just to find that this setting is turned off. They say they didn't do this, who knows... Anyways, if your whole GUI only works with GMCP enabled, being able to turn that on automatically is important
generalEnableMSDP the checkbox to enable MSDP in General preferences If your MUD uses this protocol, the GUI scripts you have for it can enable this for better player experience
generalEnableMSSP the checkbox to enable MSSP in General preferences If your MUD uses this protocol, the GUI scripts you have for it can enable this for better player experience
generalEnableMSP the checkbox to enable MSP in General preferences If your MUD uses this protocol, the GUI scripts you have for it can enable this for better player experience
inputLineStrictUnixEndings the checkbox to use strict Unix line endings in Input Line preferences If your MUD uses this, the GUI scripts you have for it can enable this for better player experience
inputLineCommandSeparator The command separator input field in Input Line preferences Some MUDs use the ; in their commands, or as a command itself. For almost all of the players on my MUD that migrated from zMUD the first question they made on our discord was "hey, why the ; stopped working for my when using Mudlet?". Presetting this to something else automatically would be a nice experience. This is a setting that is usually a user-preference but I find it really important to be able to preset it, just because of how many people asked me about this, not knowing how to change it. That would be responsibility of script-makers to inform player that this has been changed for them, or to ask them if they want that changed, before changing it
mainDisplayFixUnnecessaryLinebreaks the checkbox to fix unnecessary line breaks in Input Line preferences If your MUD needs this, the GUI scripts you have for it can enable this for better player experience
specialForceCompressionOff the checkbox to force compression off in Special preferences If your MUD needs this, the GUI scripts you have for it can enable this for better player experience
specialForceCompressionOff the checkbox to force GA off in Special preferences If your MUD needs this, the GUI scripts you have for it can enable this for better player experience
specialForceCompressionOff the checkbox to force GA off in Special preferences same as above
specialForceCompressionOff the checkbox to force GA off in Special preferences same as above
specialForceCharsetNegotiationOff the checkbox to force CHARSET negotiation off in Special preferences same as above
specialForceCharsetNegotiationOff the checkbox to force MXP negotiation off in Special preferences same as above

What's your thoughts on this? Do you think this is good idea?

@ktunkiewicz ktunkiewicz requested review from a team as code owners September 24, 2021 09:30
@add-deployment-links
Copy link

add-deployment-links bot commented Sep 24, 2021

Hey there! Thanks for helping Mudlet improve. 🌟

Test versions

You can directly test the changes here:

No need to install anything - just unzip and run.
Let us know if it works well, and if it doesn't, please give details.

@vadi2
Copy link
Member

vadi2 commented Sep 24, 2021

Haven't reviewed your PR yet (will do so later), but I'm favour of the idea. We previously discussed the design here so will definitely work with you on getting this out!

@zeddicus-pl
Copy link

zeddicus-pl commented Sep 24, 2021

Ah, great, thanks thanks that reference. I didn't see that and looks like my idea is similar to yours.
The logging of changing config values is a good idea, will add that.

IMHO we should add only a subset of settings - as I said above, the things that are not likely to be user-preference (like font size for example). Basically focus should be put into the config variables that script makers most care about.
The list can be expanded in future.

The documentation for this function will hold a table simmilar to the above, explaining what key changes what thing, what is the expected value type, value ranges etc. Along with some notes on how to use given property, if there are any specific informations regarding given key worth mentioning.

@demonnic
Copy link
Member

I can just about guarantee there'll be requests for settings we didn't think were worth putting in at first but eventually enough people ask for we feel like we have to add it. I would perhaps just go ahead and include most everything that doesn't seem like a security risk

@SlySven
Copy link
Member

SlySven commented Sep 24, 2021

inputLineCommandSeparator: IIRC We have previously discussed having the ability to set the command separator - and we came to a strong consensus that this should NOT be settable via scripts. As it is, if the user or a script wants to send several commands at once they should instead use the sendAll(...) function which is expressly provided to avoid the complications of having to know what the separator is or requiring it to be a particular character/characters...

@SlySven
Copy link
Member

SlySven commented Sep 24, 2021

mapperShow3dView: this one will have to be gated with a build-time #if defined (INCLUDE_3DMAPPER) as some builds (for the Raspberry Pi, at least) do not include the 3D map feature.

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@vadi2
Copy link
Member

vadi2 commented Sep 29, 2021

GuyD from the #includecpp discord suggested a couple of improvements to getting rid of the wall of if's - unfortunately I suspect it's a bit too much for our level of C++, but it is fascinating anyway - https://pastebin.com/rDC0p1eA and https://pastebin.com/rDC0p1eA

It's still on my list to review the PR for what it adds

@vadi2
Copy link
Member

vadi2 commented Oct 1, 2021

/refresh links

Copy link
Member

@vadi2 vadi2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I like this a lot. Especially like how you added the explanation - great to include in docs as-is.

Could you merge latest development in?

src/TLuaInterpreter.cpp Show resolved Hide resolved
host.mUSE_UNIX_EOL = getVerifiedBool(L, __func__, 2, "value");
return success();
}
if (key == "inputLineCommandSeparator") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets leave it out for now in order to get the PR through in a timely manner. See #3677 for discussion.

host.set_USE_IRE_DRIVER_BUGFIX(getVerifiedBool(L, __func__, 2, "value"));
return success();
}
if (key == "specialForceCompressionOff") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated 3x in the description of the PR

host.mMapperShowRoomBorders = (getVerifiedBool(L, __func__, 2, "value"));
return success();
}
if (key == "generalEnableGMCP") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't include general, just enableGMCP is enough.

@@ -15835,3 +15836,106 @@ int TLuaInterpreter::getMouseEvents(lua_State * L)
}
return 1;
}

int TLuaInterpreter::setMudletConfig(lua_State * L)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more concise setPreference sounds nice to me - as well as the ability to parse a table for keys, so you can use one call to set everything. It's a neater API design. Need help with parsing the table from C++ side?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second this API decision, being able to batch it by passing a table of all the things to set would be great.

}
}

lua_pushboolean(L, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to mention in the Debug console what was changed, so scripts aren't sneakily changing things from under you - example https://github.com/Mudlet/Mudlet/blob/development/src/TLuaInterpreter.cpp#L13258-L13260

@zeddicus-pl
Copy link

Thanks for all the comments, I had to switch to some other stuff for some time, but I'll get back to this soon.

@mudlet-machine-account mudlet-machine-account added this to the 4.16.0 milestone Feb 25, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2022

Messages
✔️

PR type: Addition

Generated by 🚫 dangerJS against 76d50a8

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/TLuaInterpreter.cpp Show resolved Hide resolved
@vadi2
Copy link
Member

vadi2 commented Apr 20, 2022

I'll adopt this PR, so we can get the config function into Mudlet.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/TLuaInterpreter.cpp Show resolved Hide resolved
@vadi2 vadi2 changed the title Added setMudletConfig and getMudletConfig functions Add: setConfig and getConfig functions Apr 23, 2022
@vadi2
Copy link
Member

vadi2 commented Apr 23, 2022

I don't have the rights to push to your fork @ktunkiewicz so I'll continue the work in a separate branch & PR, see #6074.

@vadi2 vadi2 closed this Apr 23, 2022
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

Successfully merging this pull request may close these issues.

None yet

8 participants