README.md edited online with Bitbucket
[swg-src.git] / tools / perllib / LightsaberAppearanceTemplate.pm
blob855781a68891e8e0f15717f03b7a0acfbd3ed1fe
1 # ======================================================================
2 # LightsaberAppearanceTemplate.pm
3 # Copyright 2003, Sony Online Entertainment
4 # All rights reserved.
5 # ======================================================================
7 package LightsaberAppearanceTemplate;
8 use strict;
10 use CustomizationVariableCollector;
11 use Iff;
13 # ======================================================================
14 # LightsaberAppearanceTemplate potentially-public variables.
15 # ======================================================================
17 # our $relativePathName;
19 # ======================================================================
20 # Setup variables that can be imported by Exporter into user modules.
21 # ======================================================================
23 use vars qw(@ISA @EXPORT_OK $VERSION);
24 use Exporter;
25 $VERSION = 1.00;
26 @ISA = qw(Exporter);
28 # These symbols are okay to export if specifically requested.
29 @EXPORT_OK = qw(&install);
31 # ======================================================================
32 # LightsaberAppearanceTemplate private variables.
33 # ======================================================================
35 my $debug = 0;
36 my $treeFileRelativeName;
38 # ======================================================================
39 # LightsaberAppearanceTemplate public functions.
40 # ======================================================================
42 sub install
44 # Register handler with CustomizationVariableCollector
45 CustomizationVariableCollector::registerHandler("LSAT", \&processIff);
48 # ======================================================================
49 # LightsaberAppearanceTemplate private functions
50 # ======================================================================
52 sub processIff
54 # Process args.
55 my $iff = shift;
56 die "bad iff arg specified" if ref($iff) ne "Iff";
58 $treeFileRelativeName = shift;
59 die "bad tree file relative name" if !defined($treeFileRelativeName);
60 print "LightsaberAppearanceTemplate: processing file [$treeFileRelativeName]\n" if $debug;
62 # Ensure we're in the proper form.
63 return 0 unless $iff->getCurrentName() eq "LSAT";
65 $iff->enterForm("LSAT");
67 my $version = $iff->getCurrentName();
68 if ($version eq "0000")
70 process_0000($iff);
72 else
74 print STDERR "LightsaberAppearanceTemplate: unsupported version tag [$version].";
75 return 0;
78 $iff->exitForm("LSAT");
80 print "LightsaberAppearanceTemplate: finished processing file [$treeFileRelativeName]\n" if $debug;
82 # Success.
83 return 1;
86 # ----------------------------------------------------------------------
88 sub process_0000
90 print "process_0000(): begin\n" if $debug;
92 my $iff = shift;
93 die 'bad $iff arg' if ref($iff) ne 'Iff';
95 $iff->enterForm("0000");
96 $iff->walkIff(\&iffWalker_0000);
97 $iff->exitForm("0000");
99 print "process_0000(): end\n" if $debug;
102 # ----------------------------------------------------------------------
104 sub iffWalker_0000
106 my $iff = shift;
107 die 'bad iff arg' if ref($iff) ne 'Iff';
109 my $blockName = shift;
110 my $isChunk = shift;
112 printf("iffWalker_0000(): %s=[%s]\n", $isChunk ? "chunk" : "form", $blockName) if $debug;
114 # Process blocks we understand.
115 if ($isChunk)
117 if ($blockName eq 'BASE')
119 # Handle specifying linked appearanceTemplate assets for blade hilt.
120 while ($iff->getChunkLengthLeft() > 0)
122 my $appearanceTemplateName = $iff->read_string();
123 CustomizationVariableCollector::logAssetLink($treeFileRelativeName, $appearanceTemplateName);
126 elsif ($blockName eq 'SHDR')
128 # Handle specifying linked shader name used for blade.
129 my $shaderTemplateName = $iff->read_string();
130 CustomizationVariableCollector::logAssetLink($treeFileRelativeName, $shaderTemplateName);
134 # HACK???
135 # The C++ code for the Lightsaber appearance depends on this Customization variable to implement
136 # the alternate shader scheme (used for lava sabers). This variable is not referenced by any other
137 # kind of asset, but if the CustomizationVariableCollector doesn't find it, it cannot be used.
138 # We could make it part of the LightsaberAppearanceTemplate, but it would effectively be hard-coded there,
139 # and never change across instances of that template. So I am hard-coding it here, to express the
140 # code's implicit dependency.
141 # Upping this variable from 2 to 16 for Permafrost saber and any others we think of, so no one needs
142 # to find this crazy line of code again. - Matt B. 9/18/08
143 CustomizationVariableCollector::logBasicRangedIntVariable($treeFileRelativeName, "private/alternate_shader_blade", 0, 16, 0);
146 # Keep traversing.
147 return 1;
150 # ======================================================================