Welcome to IOPWiki, Commander.
We are searching for editors to complete gameplay topics in all games. You can contribute without an account. Learn how to contribute and join our Discord server.

Widget:costumeSwitcher: Difference between revisions

Welcome to IOP Wiki. This website is maintained by the Girls' Frontline community and is free to edit by anyone.
Jump to navigation Jump to search
Setting the dorm spritemap for the selected option of the costume
Added document-ready wait functionality as the MediaWiki does not wait for DOM
 
(18 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<includeonly><script>
<includeonly><script>
RLQ.push(['jquery', function () {
  $(document).ready(function() {
    // Let's make sure the correct values are shown
    $('.modswitcher').change();
  });
}]);
function swap_mod(element) {
  var selectBox = $(element);
  var selectedValue = selectBox.find(':selected').val();
  var tmp = new DOMParser().parseFromString(selectedValue, "text/html");
  var tdollData = jQuery.parseJSON(tmp.documentElement.textContent);
 
  var statContainer = selectBox.closest('.stattable');
 
  tdollData = updateCalculatedValues(tdollData);
 
  for (var key in tdollData) {
    if (tdollData.hasOwnProperty(key)) {
      var valField = statContainer.find('*[data-tdoll-stat-id="' + key + '"]');
      var newValue = tdollData[key];
      valField.text(newValue);
    }
  }
  // ToDo: find a better way of finding out if it's a mod
  // ToDo: find a better way of telling which skills are available with which mod
  var isMod = selectBox.find(':selected').text().indexOf('MOD') >= 0;
  statContainer.find('.skillform .tabButtonLane button').last().toggle(isMod);
 
  // With mod-change the visible skillbuttons might change, too, so trigger the last visible one
  // For now it only has to be set if we change to Base, as it has only one skill
  if (!isMod) {
    statContainer.find('.skillform .tabButtonLane button:visible').last().click();
  }
}
function updateCalculatedValues(data) {
  var ret = data;
 
  // Calculating Max HP for full dummied T-Doll
  if (ret.hasOwnProperty("max_hp_t")) {
    ret.hpmaxwd = ret.max_hp_t * 5;
  }
 
  return ret;
}
function swap_costume(element) {
function swap_costume(element) {
     var neededGadgets = [ 'ext.gadget.md5hasher' ];
     var neededGadgets = [ 'ext.gadget.md5hasher' ];
Line 22: Line 70:
         var chibiCostumeName = "";
         var chibiCostumeName = "";
         if (costumeSelectionIndex != 0) {
         if (costumeSelectionIndex != 0) {
           chibiCostumeName = "_costume" + costumeSelectionIndex;
           chibiCostumeName = "_costume" + costumeSelectionIndex
         }
         }
        var selectedOption = selectBox.find(':selected');
        selectBox.closest('.costumeContainer').find('.tdoll_chibi').attr('data-tdoll-use-dorm-spritemap', selectedOption.attr('data-tdoll-use-dorm-spritemap')=="true");


         selectBox.closest('.costumeContainer').find('.chibiAnimation,.live2dAnimation,.artTab').trigger("costume_changed", chibiCostumeName);
         selectBox.closest('.costumeContainer').find('.chibiAnimation,.live2dAnimation,.artTab').trigger("costume_changed", chibiCostumeName);
          
          
         var basePath = "http://en.gfwiki.com/images/"; // ToDo: find a better way to find out the base path
         var basePath = "https://en.gfwiki.com/images/"; // ToDo: find a better way to find out the base path
         var tdollId = selectBox.closest('.costumeContainer').find('.tdoll_chibi').data('tdollId');
         var tdollId = selectBox.closest('.costumeContainer').find('.tdoll_chibi').data('tdollId');
         var costumeId = tdollId + chibiCostumeName;
         var costumeId = tdollId + chibiCostumeName;
Line 42: Line 87:
         $("#fullart_S").attr("srcset", fullartSPath);
         $("#fullart_S").attr("srcset", fullartSPath);


         $(".tdoll_chibi img").attr("src", chibiPath);
         $(".tdoll_chibi>img").attr("src", chibiPath);
          
          
         // As we change the link, we have to update the Thumb-Cache of the Media Viewer
         // As we change the link, we have to update the Thumb-Cache of the Media Viewer
Line 57: Line 102:
}
}


</script><select style="background-color:rgba(250,250,250,0.9);width:100%;height: 21px;text-align:center;border: none;color: rgb(63,63,63);" autocomplete="off" onchange="swap_costume(this)" >
</script>
<div style="display:flex">
<!--{if $moddable neq ''}--><select class="gf-droplist modswitcher" style="padding-left: 2px;padding-right: 8px;margin-right: 2px;" autocomplete="off" onchange="swap_mod(this)">
<option value='<!--{$defaultstats|escape:'html'}-->'>BASE</option>
<option value='<!--{$mod1stats|escape:'html'}-->'>MOD1</option>
<option value='<!--{$mod2stats|escape:'html'}-->'>MOD2</option>
<option value='<!--{$mod3stats|escape:'html'}-->' selected="selected">MOD3</option>
</select><!--{/if}-->
<select class="gf-droplist" style="flex-grow: 1;" autocomplete="off" onchange="swap_costume(this)" >
<option value="<!--{$defaultpaths|escape:'html'}-->" selected="selected">Default</option>
<option value="<!--{$defaultpaths|escape:'html'}-->" selected="selected">Default</option>
<!--{if $costume1name neq ''}--><option value="<!--{$costume1paths|escape:'html'}-->"><!--{$costume1name|escape:'html'}--></option><!--{/if}-->
<!--{if $costume1name neq ''}--><option value="<!--{$costume1paths|escape:'html'}-->"><!--{$costume1name|escape:'html'}--></option><!--{/if}-->
Line 64: Line 117:
<!--{if $costume4name neq ''}--><option value="<!--{$costume4paths|escape:'html'}-->"><!--{$costume4name|escape:'html'}--></option><!--{/if}-->
<!--{if $costume4name neq ''}--><option value="<!--{$costume4paths|escape:'html'}-->"><!--{$costume4name|escape:'html'}--></option><!--{/if}-->
<!--{if $costume5name neq ''}--><option value="<!--{$costume5paths|escape:'html'}-->"><!--{$costume5name|escape:'html'}--></option><!--{/if}-->
<!--{if $costume5name neq ''}--><option value="<!--{$costume5paths|escape:'html'}-->"><!--{$costume5name|escape:'html'}--></option><!--{/if}-->
</select></includeonly>
</select></div></includeonly>


<noinclude>
<noinclude>
Line 72: Line 125:
|defaultpaths={{filepath:Springfield.png|420}},,{{filepath:Springfield_D.png|420}},,{{filepath:Springfield_S.png|420}},,{{filepath:Springfield_chibi.png|420}}
|defaultpaths={{filepath:Springfield.png|420}},,{{filepath:Springfield_D.png|420}},,{{filepath:Springfield_S.png|420}},,{{filepath:Springfield_chibi.png|420}}
|costume1name=test1
|costume1name=test1
|moddable=1
|costume1paths={{filepath:Springfield_costume1.png|420}},,{{filepath:Springfield_costume1_D.png|420}},,{{filepath:Springfield_costume1_S.png|420}},,{{filepath:Springfield_costume1_chibi.png|420}}
|costume1paths={{filepath:Springfield_costume1.png|420}},,{{filepath:Springfield_costume1_D.png|420}},,{{filepath:Springfield_costume1_S.png|420}},,{{filepath:Springfield_costume1_chibi.png|420}}
|costume2name=test2
|costume2name=test2

Latest revision as of 15:07, 14 October 2019


test