Jump to content
Korean Random
SmashPuppet

XVM Config/Mod Version Checker (Widget)

Recommended Posts

I wanted to display the version status of my config in the hangar to let others know when a new version is up.

So I made one for XVM to use in the hangar and login via widgets with a simple script and thought that other custom config authors might want to use it for their own config pack as well.

 

Because it was asked and because ktulho made a script that allows clickable links via widgets, I've completely updated the script(s).

 

The display updates itself after every battle. (When the hangar is reloaded)

 

Again, this is only useful and meant for config authors. If you do not make and distribute your own config, this is probably not for you.

 

Images:

 

 


 

Status Current:
shot_013.thumb.jpg.abdc537143dc90ba4c9479b9cf6dd0df.jpg

Status Update Available (after a click):

5b272d932b8ff_WorldOfTanks2018-06-1720-54-30-26.thumb.png.d5aa6e395a94dbf1c34a178aa884f489.png
 

There is also a notification if there is a network error as well as a version conflict - (you have a newer version than what is currently online).
 

 
2

 

Installation:

 

Add this line to your @xvm.xc file. I put mine just after the hangar entry.

 

 


    "configVersionCheck": ${"configCheck.xc":"configVersionCheck"},     // Check custom config version
 

 

 

Add this to your widgets.xc file in the login and lobby section.

 

 

Login section:
${ "widgetsTemplates.xc":"configVersionLogin" }

 

Lobby section:

${ "widgetsTemplates.xc":"configVersionHangar" }

 

 

 

Add this to your widgetsTemplates.xc file. (don't forget to add the comma at the end if you need to. Depends on where you paste)

 

 

// Config Version Check at Login Screen
  "configVersionLogin": {
    "enabled": true,
    "layer": "top",
    "type": "extrafield",
    "formats": [
      { "updateEvent": "PY(ON_OPEN_BROWSER)",
        "x": 5,
        "y": 80,
        "screenHAlign": "left",
        "width": "{{py:cvc.checkVersion=1?350|200",
        "height": 30,
        "textFormat": { "color": "{{py:ob.highlight?{{.configVersionCheck.settings.currentColor}}|{{.configVersionCheck.settings.updateColor}}}}", "size": 15},
        "format": "{{.configVersionCheck.settings.logo}}<font>{{.configVersionCheck.settings.configName}} {{py:cvc.checkVersion=0?<font color='{{.configVersionCheck.settings.currentColor}}'>{{.configVersionCheck.settings.version}} {{.configVersionCheck.settings.currentConfig}}</font>|{{py:cvc.checkVersion<0?<u>{{.configVersionCheck.settings.updateConfig}}</u>{{py:ob.address('{{.configVersionCheck.links.updateLink}}')}}|{{py:cvc.checkVersion>0?{{.configVersionCheck.settings.versionConflict}} <u>{{.configVersionCheck.settings.conflictInstruction}}</u>{{py:ob.address('{{.configVersionCheck.links.updateLink}}')}}}}}}}}</font>",
        "mouseEvents": {"mouseDown": "openBrowser_Down", "mouseOver": "openBrowser_Over", "mouseOut": "openBrowser_Out"}
      }
    ]
  },
// Config Version Check in Hangar
  "configVersionHangar": {
    "enabled": true,
    "layer": "top",
    "type": "extrafield",
    "formats": [
      { "updateEvent": "PY(ON_OPEN_BROWSER)",
        "x": -280,
        "y": 50,
        "screenHAlign": "right",
        "width": "{{py:cvc.checkVersion=1?350|200",
        "height": 30,
        "textFormat": { "color": "{{py:ob.highlight?{{.configVersionCheck.settings.currentColor}}|{{.configVersionCheck.settings.updateColor}}}}", "size": 15},
        "format": "{{.configVersionCheck.settings.logo}}<font>{{.configVersionCheck.settings.configName}} {{py:cvc.checkVersion=0?<font color='{{.configVersionCheck.settings.currentColor}}'>{{.configVersionCheck.settings.version}} {{.configVersionCheck.settings.currentConfig}}</font>|{{py:cvc.checkVersion<0?<u>{{.configVersionCheck.settings.updateConfig}}</u>{{py:ob.address('{{.configVersionCheck.links.updateLink}}')}}|{{py:cvc.checkVersion>0?{{.configVersionCheck.settings.versionConflict}} <u>{{.configVersionCheck.settings.conflictInstruction}}</u>{{py:ob.address('{{.configVersionCheck.links.updateLink}}')}}}}}}}}</font>",
        "mouseEvents": {"mouseDown": "openBrowser_Down", "mouseOver": "openBrowser_Over", "mouseOut": "openBrowser_Out"}
      }
    ]
  }

 

 

 

Add these scripts to your py_macro folder.

 configVersionCheck.py  {{py:cvc.checkVersion}} returns -1 if update, 0 if current and 1 if version conflict (you are using newer than what is online)

 openBrowser.py Modified (originally from this topic)

 

Add this .xc file to your config folder. Edit the settings according to your own needs. It has my own settings in it and will probably not be useful to you as is!

 

configCheck.xc

 

And as an example, create a text file ( .txt ) and write your config version into it. Keep it small and concise. It can read any text-based document but a text file is simplest. Currently, the script does not allow for alphanumerics. Only numerics. - (Python's StrictVersion library)

Example:

 

 


1.9.8
 

 

 

You will of course, need to upload this text file to a remote HTTP server and edit your config to match its URL. Every time you change your version number, package up your config after the necessary edits and then upload a new text file, containing the latest version number.

 

If you host your own site, you should already be familiar with mod_rewrite and/or .htaccess files (assuming your host server is Unix/Linux (Apache etc) based). You may need to do some editing in order to access a file with a .txt extension. Just ask if you run into issues... I or someone here may be able to help you.

 

Here is the provided settings file, configCheck.xc

 

 

// Simple Config Version Checker for your Hangar. configVersionCheck.py ~ SmashPuppet (NA) 2018
{
"configVersionCheck": {
    "enabled": true,
    "settings": {
        "version":              "2.0.6", // Text to search for in remote file/document. Change it to your current version number before packaging config!
        "configName":           "SmashConfig", // The name of your xvm configuration.
        "logo":                 "<img src='xvm://res/clanicons/NA/nick/SmashPuppet.png' vspace='-4' width='22' height='22'>", // your chosen config logo
        "updateConfig":         "New Version!", // Text to display when a new version is available.
        "updateColor":          "{{py:replace('{{.colors.system.enemy_alive}}', '0x', '#')}}", // The colour of the update text. (HTML colours)
        "currentConfig":        "is Current.", // Text to display if configuration is current.
        "currentColor":         "{{py:replace('{{.colors.system.ally_alive}}', '0x', '#')}}", // The colour of the current text. (HTML colours)
        "updateInstruction":    "<b>Press F8</b> to view update.", // Text to display about updating
        "notAvailable":         "Information not available!", // Text to display if network error.
        "versionConflict":      "Version Conflict!", // Text to display if online version is older than current version.
        "conflictInstruction":  "Check configCheck.xc!", // Text to display about a version conflict. IE if your version is newer than what is online.
        "internalBrowser":      false // true - use the in-game web browser. false - use external web browser.
    },
    "links": {
        "remoteLink": "https://smashpuppet.net/SmashConfig/version.txt", // link to remote text file containing the version text.
        "updateLink": "https://smashpuppet.net/smashconfig" // The update URL to get latest configuration.
    }
  }
}

 

 
 
 

 

Like I said, it is very simple. There is one catch, you cannot actually download anything from download links in the internal browser. If you would like to use your default desktop browser, then edit configVersionCheck.xc and make sure that "internalBrowser" is set to false.

Many thanks to everyone here and the XVM devs for their tireless work.

I hope you find this useful.

Cheers!

 

 

 

Edited by SmashPuppet
Update August 31, 2018
  • Upvote 4

Share this post


Link to post

Short link
Share on other sites
On 4/7/2018 at 2:04 PM, sicfunzler said:

Is not it possible to directly make a link that you can click ???

 

So you can directly download the mod

 

MFG

SicFunzler


It might be if I had used a button that is similar to the "store" for instance. Or if I had used the notifications centre at the bottom. Like XVM does. But I was going for very simple and something that will most likely not break in new versions of the game. Many of the other version checkers are no longer working after being abandoned. 

I will look into it though when I have time. Cheers!

  • Upvote 2

Share this post


Link to post

Short link
Share on other sites

Didn't he mean the link here on the forums to download the whole thing, instead of individual files? At least that's how I understood it.

Edited by konrad509

Share this post


Link to post

Short link
Share on other sites
22 hours ago, konrad509 said:

Didn't he mean the link here on the forums to download the whole thing, instead of individual files? At least that's how I understood it.

 

44 minutes ago, sicfunzler said:

Thx Man pls look when you have time !!!

 

MFG

SicFunzler


Good points both. Cheers!

Share this post


Link to post

Short link
Share on other sites

(This reply is no longer relevant)

I finally found some time. =) I've made a few changes with the suggestions made in mind. Although you cannot download the update directly from within the hangar with this, you can however, hit a function key (in this case F8) to open the awesomium browser and view the update online from within the hangar. Borrowing some inspiration from @ktulho's siteXVM.py addon with a few changes. (Many thanks for his tireless work and sharing!)...

I've also made the version comparison a little more intelligent than the original.
I'll leave the main post as is for some may still want it as simple as can be.

 

Installation is still the same as above. Configure the configCheck.xc, login.xc and widgetsTemplates.xc to your own parameters of course.

 

Changed files:

configVersionCheck.py

configCheck.xc

 

widgets.xc add/change these entries:

 

 


/**
 * List of widgets.
 * Список виджетов.
 */
{
  "widgets": {
    "login": [
    ${ "widgetsTemplates.xc":"configVersionLogin" }
    ],
    "lobby": [
      ${ "widgetsTemplates.xc":"configVersionHangar" }
    ]
  }
}
 

 

 

widgetsTemplates.xc add/change these entries:

 

 


// Config Version Check at Login Screen
  "configVersionLogin": {
    "enabled": true,
    "layer": "top",
    "type": "extrafield",
    "formats": [
      { "x": 5,
        "y": 80,
        "screenHAlign": "left",
        "width": 400,
        "height": 60,
        "textFormat": { "color": "0xA8A888", "size": 12},
        "format": "<img src='xvm://res/clanicons/{{region}}/nick/SmashPuppet.png' vspace='-4' width='22' height='22'><font size='15'>{{py:cvc.checkVersion}}</font>"
      }
    ]
  },
// Config Version Check in Hangar
  "configVersionHangar": {
    "enabled": true,
    "layer": "top",
    "type": "extrafield",
    "formats": [
      { "x": -180,
        "y": 50,
        "screenHAlign": "right",
        "width": 400,
        "height": 60,
        "textFormat": { "color": "0xA8A888", "size": 12},
        "format": "<img src='xvm://res/clanicons/{{region}}/nick/SmashPuppet.png' vspace='-4' width='22' height='22'><font size='15'>{{py:cvc.checkVersion}}</font>"
      }
 

 

 

...and that should be about it for changing it from a simple checker to something a little more "flashy". ;) 

 

Screenshot of Login Screen

 

 


5b14347930f54_WorldOfTanks2018-06-0311-32-16-41.thumb.png.bcc234a0ac4fde663b66acc9c5e1a3f7.png
 

 

 

Enjoy!

 




 

Edited by SmashPuppet

Share this post


Link to post

Short link
Share on other sites
Только что, sicfunzler сказал:

I hear ther are Problems with WG when you take the Browser form WG ????

 

MFG

SicFunzler

 

Edited by sicfunzler

Share this post


Link to post

Short link
Share on other sites
5 hours ago, sicfunzler said:

 

 

So far for my own page, the only thing that does not work is actually downloading a file.

I was thinking of using a key press to download a file to the local drive. Getting the file URL from the config and placing it in the system's default downloads folder.
 

Or, perhaps I can make a choice to use the internal or external browser(s). Of course, I would need to find out how opening an external browser works! Haha

 

EDIT: Oh ok. I figured it out. I will update the main post soon.

 

Added new option in configVersionCheck.xc.

"internalBrowser":      false // true - use the in-game web browser. false - use external web browser.

 

Small modification to ktulho's openBrowser.py script.

 

Updated main post.

Edited by SmashPuppet

Share this post


Link to post

Short link
Share on other sites

I am not sure but maybe this thread would be better served in Components of XVM and addons (py_macro) section.

Edit: Thank you Mr. Moderator! ;) 
 

Edited by SmashPuppet
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites
9 hours ago, sicfunzler said:

Hello man i need a update for openBrowser.py Modified (originally from this topic)

 

THX man

MFG

SicFunzler


Working on it! =D I might have to ask in the forums here if I can't find what changed. As soon as I have a solution, it will be posted here.
In the meantime, set the config to use the internal browser.

OK, first my apologies. I had thought the script was broken for different reasons than it was. Here it is and I will update the main post in a short while.


Modified from kthulo's original script:
openBrowser.py

Cheers!

Updated main post...

Edited by SmashPuppet

Share this post


Link to post

Short link
Share on other sites

2018-11-30 18:00:00.538: ERROR: [EXCEPTION] (res_mods/configs/xvm/py_macro\configVersionCheck.py, 59):
Traceback (most recent call last):
  File "res_mods/configs/xvm/py_macro\configVersionCheck.py", line 56, in checkVersion
    cmp = vMatch(search, page)
  File "res_mods/configs/xvm/py_macro\configVersionCheck.py", line 55, in <lambda>
    vMatch = lambda search, page: StrictVersion(search).__cmp__(page)
  File "scripts/common/Lib/distutils/version.py", line 40, in __init__
  File "scripts/common/Lib/distutils/version.py", line 107, in parse
ValueError: invalid version number '118'


2018-12-01 00:19:04.830: ERROR: [EXCEPTION] (res_mods/configs/xvm/py_macro\configVersionCheck.py, 59):
Traceback (most recent call last):
  File "res_mods/configs/xvm/py_macro\configVersionCheck.py", line 56, in checkVersion
    cmp = vMatch(search, page)
  File "res_mods/configs/xvm/py_macro\configVersionCheck.py", line 55, in <lambda>
    vMatch = lambda search, page: StrictVersion(search).__cmp__(page)
  File "scripts/common/Lib/distutils/version.py", line 40, in __init__
  File "scripts/common/Lib/distutils/version.py", line 107, in parse
ValueError: invalid version number '120'

 

Now know the Problem:

when i give Version only 120 came ERROR

When i give Version 1.2.120 it go :) ;) :)

 

MFG

SicFunzler

 


 

 

Edited by sicfunzler

Share this post


Link to post

Short link
Share on other sites
On 11/30/2018 at 8:04 AM, sicfunzler said:

2018-11-30 18:00:00.538: ERROR: [EXCEPTION] (res_mods/configs/xvm/py_macro\configVersionCheck.py, 59):
Traceback (most recent call last):
  File "res_mods/configs/xvm/py_macro\configVersionCheck.py", line 56, in checkVersion
    cmp = vMatch(search, page)
  File "res_mods/configs/xvm/py_macro\configVersionCheck.py", line 55, in <lambda>
    vMatch = lambda search, page: StrictVersion(search).__cmp__(page)
  File "scripts/common/Lib/distutils/version.py", line 40, in __init__
  File "scripts/common/Lib/distutils/version.py", line 107, in parse
ValueError: invalid version number '118'


2018-12-01 00:19:04.830: ERROR: [EXCEPTION] (res_mods/configs/xvm/py_macro\configVersionCheck.py, 59):
Traceback (most recent call last):
  File "res_mods/configs/xvm/py_macro\configVersionCheck.py", line 56, in checkVersion
    cmp = vMatch(search, page)
  File "res_mods/configs/xvm/py_macro\configVersionCheck.py", line 55, in <lambda>
    vMatch = lambda search, page: StrictVersion(search).__cmp__(page)
  File "scripts/common/Lib/distutils/version.py", line 40, in __init__
  File "scripts/common/Lib/distutils/version.py", line 107, in parse
ValueError: invalid version number '120'

 

Now know the Problem:

when i give Version only 120 came ERROR

When i give Version 1.2.120 it go :) ;) :)

 

MFG

SicFunzler

 


 

 


Yes, the python uses "strict" versioning checks. Glad you figured it out. Cheers! =) 

  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...