Remove key-mod attribute from dialog schema

- Modifiers are now given in the def-key attribute, as originally intended
- Dialogs that have a help button now assign F1 to that button (replacing shift+/ in some cases)
- F1 also brings up help in the main game (in addition to shift+/)
This commit is contained in:
2015-10-03 00:53:32 -04:00
parent edaf3baa2d
commit 03bc3d05e6
12 changed files with 46 additions and 120 deletions

View File

@@ -1722,6 +1722,9 @@ bool handle_keystroke(sf::Event& event){
}
char chr = keyToChar(chr2, event.key.shift);
// F1 should bring up help.
// TODO: So should the help key, if it exists (but SFML doesn't support the help key)
if(chr2 == kb::F1) chr = '?';
switch(chr) {

View File

@@ -123,9 +123,6 @@ std::string cButton::parse(ticpp::Element& who, std::string fname) {
std::string name, id;
int width = 0, height = 0;
bool foundType = false, foundTop = false, foundLeft = false; // required attributes
bool foundKey = false;
std::string keyMod, keyMain;
int keyModRow, keyModCol, keyMainRow, keyMainCol;
rectangle frame;
for(attr = attr.begin(&who); attr != attr.end(); attr++){
attr->GetName(&name);
@@ -176,15 +173,13 @@ std::string cButton::parse(ticpp::Element& who, std::string fname) {
}
setColour(clr);
}else if(name == "def-key"){
attr->GetValue(&keyMain);
foundKey = true;
keyMainRow = attr->Row();
keyMainCol = attr->Column();
}else if(name == "key-mod"){
attr->GetValue(&keyMod);
foundKey = true;
keyModRow = attr->Row();
keyModCol = attr->Column();
std::string val;
attr->GetValue(&val);
try{
attachKey(parseKey(val));
}catch(int){
throw xBadVal("button",name,val,attr->Row(),attr->Column(),fname);
}
// }else if(name == "fromlist"){
// attr->GetValue(&fromList);
}else if(name == "top"){
@@ -202,20 +197,6 @@ std::string cButton::parse(ticpp::Element& who, std::string fname) {
if(!foundType) throw xMissingAttr("button","type",who.Row(),who.Column(),fname);
if(!foundTop) throw xMissingAttr("button","top",who.Row(),who.Column(),fname);
if(!foundLeft) throw xMissingAttr("button","left",who.Row(),who.Column(),fname);
if(foundKey) {
cKey theKey;
try{
theKey = parseKey(keyMod + " " + keyMain);
}catch(int){
try {
theKey = parseKey(keyMain);
}catch(int){
throw xBadVal("button","def-key",keyMain,keyMainRow,keyMainCol,fname);
}
throw xBadVal("button","key-mod",keyMod,keyModRow,keyModCol,fname);
}
attachKey(theKey);
}
switch(getBtnType()){
case BTN_SM:
frame.right = frame.left + 23;

View File

@@ -516,7 +516,6 @@ std::string cPict::parse(ticpp::Element& who, std::string fname) {
}else if(name == "def-key"){
std::string val;
attr->GetValue(&val);
// TODO: The modifiers are now in key-mod, so this needs to be updated
try{
attachKey(parseKey(val));
}catch(int){

View File

@@ -28,7 +28,7 @@ rect of the control within the dialog. All non-container controls
support these attributes, and in fact the `top` and `left` attributes
are required. Some controls may ignore the `width` and `height`
attributes.
* `def-key`, `key-mod` - Specifies the default keyboard shortcut for the
* `def-key` - Specifies the default keyboard shortcut for the
control. See **Keyboard Shortcuts** below for more information on the
format of these attributes.
* `font`, `size`, `color`, `colour` - Specifies text attributes of the
@@ -70,7 +70,7 @@ either `true` or `false`; defaults to `false`.
* `clickable` - Specifies that the text is clickable. This attribute is
useless, as clickability is determined solely by having a click handler
set in the code.
* `fromlist`, `font`, `size`, `color`, `colour`, `def-key`, `key-mod` -
* `fromlist`, `font`, `size`, `color`, `colour`, `def-key` -
See **Common Attributes** above.
The `<button>` tag
@@ -89,7 +89,7 @@ The `<button>` tag accepts the following attributes:
* `type` - Specifies the type of button. This attribute is required.
* `wrap` - Specifies whether to wrap the text on the button. Can be
either `true` or `false`; defaults to `false`.
* `fromlist`, `def-key`, `key-mod` - See **Common Attributes** above.
* `fromlist`, `def-key` - See **Common Attributes** above.
The possible values for the `type` attribute are:
@@ -162,7 +162,7 @@ either `true` or `false`; defaults to `false`.
be either `true` or `false`; defaults to `true`.
* `size` - For certain types of graphics, this provides an additional
hint. Can be one of `small`, `wide`, `tall`, or `large`.
* `def-key`, `key-mod` - See **Common Attributes** above.
* `def-key` - See **Common Attributes** above.
The possible values for the `type` attribute are:
@@ -252,10 +252,10 @@ be either `true` or `false`; defaults to `true`.
Keyboard Shortcuts
------------------
Keyboard shortcuts are specified with a pair of attributes.
Keyboard shortcuts are specified with the `def-key` attribute.
The `def-key` attribute specifies the main key that triggers the
control. It can take any of the following values:
The `def-key` attribute is a space separated list of values. The final value in this list
specifies the main key that triggers the control. It can be any of the following values:
* A single digit
* A lowercase letter
@@ -274,15 +274,18 @@ is implemented though.)
* `tab` - The tab key.
* `help` - The help key (on keyboards that have one) or the F1 key.
* `space` - The space key.
* `none` - No key shortcut (the default).
The `key-mod` attribute contains a space-separated list of any of the
following values:
Preceding values in the `def-key` attribute specify the modifiers to be used with the key.
Any of the following values is allowed:
* `ctrl` - The primary accelerator key (either control or command).
* `shift` - The shift key
* `alt` - The alt or option key
The following special value is also allowed for the `def-key` attribute:
* `none` - No key shortcut (the default).
Text Formatting
---------------