Merge branch 'master' of https://Governor-Tarkin@bitbucket.org/Governor-Tarkin/swg...
[swg-src.git] / tools / perllib / DetailAppearanceTemplate.pm
blobf5834c3b02f2d5aa5ba7161d3ff8ff7c09bcad4c
1 # ======================================================================
2 # DetailAppearanceTemplate.pm
3 # Copyright 2003, Sony Online Entertainment
4 # All rights reserved.
5 # ======================================================================
7 package DetailAppearanceTemplate;
8 use strict;
10 use CustomizationVariableCollector;
11 use Iff;
13 # ======================================================================
14 # DetailAppearanceTemplate 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 # DetailAppearanceTemplate private variables.
33 # ======================================================================
35 my $debug = 0;
36 my $treeFileRelativeName;
38 # ======================================================================
39 # DetailAppearanceTemplate public functions.
40 # ======================================================================
42 sub install
44 # Register handler with CustomizationVariableCollector
45 CustomizationVariableCollector::registerHandler("DTLA", \&processIff);
48 # ======================================================================
49 # DetailAppearanceTemplate 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 "DetailAppearanceTemplate: processing file [$treeFileRelativeName]\n" if $debug;
62 # Ensure we're in the proper form.
63 return 0 unless $iff->getCurrentName() eq "DTLA";
65 $iff->enterForm("DTLA");
67 my $version = $iff->getCurrentName();
68 if ($version =~ m/^000[1-8]$/)
70 process_0001_0008($iff);
72 else
74 print STDERR "DetailAppearanceTemplate: unsupported version tag [$version].";
75 return 0;
78 $iff->exitForm("DTLA");
80 print "DetailAppearanceTemplate: finished processing file [$treeFileRelativeName]\n" if $debug;
82 # Success.
83 return 1;
86 # ----------------------------------------------------------------------
88 sub process_0001_0008
90 print "process_0001_0008(): begin\n" if $debug;
92 my $iff = shift;
93 die 'bad $iff arg' if ref($iff) ne 'Iff';
95 $iff->enterForm();
97 $iff->walkIff(\&iffWalker_0001_0008);
99 $iff->exitForm();
101 print "process_0001_0008(): end\n" if $debug;
104 # ----------------------------------------------------------------------
106 sub iffWalker_0001_0008
108 my $iff = shift;
109 die 'bad iff arg' if ref($iff) ne 'Iff';
111 my $blockName = shift;
112 my $isChunk = shift;
114 printf("iffWalker_0001_0008(): %s=[%s]\n", $isChunk ? "chunk" : "form", $blockName) if $debug;
116 # Process blocks we understand.
117 if ($isChunk)
119 if ($blockName eq 'CHLD')
121 # Handle specifying linked appearance template assets.
122 $iff->skipBytes(4);
124 # NOTE: this is sneaky: appearances are missing the leading 'appearance/'.
125 # This burned me first time around.
126 my $appearanceTemplateName = 'appearance/' . $iff->read_string();
127 CustomizationVariableCollector::logAssetLink($treeFileRelativeName, $appearanceTemplateName);
131 # Keep traversing.
132 return 1;
135 # ======================================================================