Welcome to IOPWiki, Commander.
We are searching for new editors to keep track of Girls' Frontline 2 content, as well as veteran players to complete the data of Girls' Frontline and Project Neural Cloud characters.
You can contribute without an account. Learn how to contribute and join our Discord server.

Widget:Live2DSwitcher: 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
loaded missing resources
Added document-ready wait functionality as the MediaWiki does not wait for DOM
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><script>
<includeonly><div><script>
RLQ.push(function () {
RLQ.push(['jquery', function () {
   $(document).ready(function() {
   $(document).ready(function() {
     var containers = $('.dollLive2d');
     var containers = $('.dollLive2d');
     if (containers.length < 1) return;
     if (containers.length < 1) return;


     containers.each(function() {
     containers.each(function(idx, val) {
       mw.loader.using('ext.gadget.live2d').then(function() {
       var container = $(val);
         var ul = $(this).find('ul');
      var doll = container.data('t-doll');
         var settings = gfUtils.live2dUtils.convertSettingsFromUl(ul);
     
         console.log(settings);
      container.on("live2dloaded", function(event) {
        container.find('.live2dswitcher option').remove();
         var settingsContainer = container.find('.live2dsettings').first();
         var settings = gfUtils.live2dUtils.convertSettingsFromUl(settingsContainer);
         for (var idx=0; idx<settings.length; idx++) {
          var currentSettings = settings[idx];
          for (variant in currentSettings) {
            if (variant == "costumeId") {
              continue;
            }
           
            var id = doll + "|" + currentSettings.costumeId + "|" + variant;
            var name = currentSettings[variant].name;
            if (!name) {
              name = currentSettings.costumeId + " - " + variant;
            }
            container.find('.live2dswitcher').append($('<option>', {
              value: id,
              text: name
            }));
          }
        }
       });
       });
     });
     });
   });
   });
});
}]);


function swap_module(element) {
function swap_model(element) {
   var selectBox = $(element);
   var selectBox = $(element);
   var containerDiv = selectBox.parent();
   var containerDiv = selectBox.closest('.dollLive2d');
          
          
   var selectedValue = selectBox.val();
   var selectedValue = selectBox.val();
Line 33: Line 54:


</script>
</script>
<select class="gf-droplist" style="flex-grow: 1;" autocomplete="off" onchange="swap_model(this)" >
<label>Costume:</label><select class="gf-droplist live2dswitcher" style="flex-grow: 1;" autocomplete="off" onchange="swap_model(this)" >
<!--<option value="<!--{$defaultpaths|escape:'html'}-->" selected="selected"></option>-->
<option value="" selected="selected">Loading...</option>
</select></includeonly><noinclude>
</select></div></includeonly><noinclude>
<div class="dollLive2d" style="height: 800px; width: 700px;">
<div class="dollLive2d" data-live2d-needed="true" data-t-doll="Thompson" data-costume="costume1" style="height: 800px; width: 700px;">
{{#widget:Live2DSwitcher}}
{{#widget:Live2DSwitcher}}
<div class="live2dsettings" style="display:none">{{:Thompson/Live2DSettings}}</div>
<div class="live2dsettings" style="display:none">{{:Thompson/Live2DSettings}}</div>
</div>
</div>
</noinclude>
</noinclude>

Latest revision as of 15:12, 14 October 2019