Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Niflib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grant Kim
Niflib
Commits
182be3da
Commit
182be3da
authored
19 years ago
by
Shon Ferguson
Browse files
Options
Downloads
Patches
Plain Diff
Finished implementing NiControllerSequence and interface.
parent
166a7738
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NIF_Blocks.cpp
+109
-48
109 additions, 48 deletions
NIF_Blocks.cpp
NIF_Blocks.h
+3
-3
3 additions, 3 deletions
NIF_Blocks.h
niflib.h
+3
-3
3 additions, 3 deletions
niflib.h
with
115 additions
and
54 deletions
NIF_Blocks.cpp
+
109
−
48
View file @
182be3da
...
...
@@ -3764,54 +3764,115 @@ NiControllerSequence::~NiControllerSequence() {
}
}
//void NiControllerSequence::SetFirstTargetName( string new_name ) {
// _first_child.first = new_name;
//}
//
//void NiControllerSequence::SetFirstController( blk_ref new_link ) {
// //Check for identical values
// if ( new_link == _first_child.second )
// return;
//
// //Remove old child
// if ( _first_child.second.is_null() == false ) {
// RemoveChild( _first_child.second.get_block() );
// }
//
// //Set new value
// _first_child.second = new_link;
//
// //Add new child
// if ( _first_child.second.is_null() == false ) {
// AddChild( _first_child.second.get_block() );
// }
//}
//
//void NiControllerSequence::AddController( string new_name, blk_ref new_link ) {
// //Make sure the link isn't null
// if ( new_link.is_null() == true ) {
// throw runtime_error("Attempted to add a null link to NiControllerSequence block.");
// }
//
// _children.push_back( pair<string,blk_ref>(new_name, new_link) );
//
// //Add new child
// AddChild( new_link.get_block() );
//}
//
//void NiControllerSequence::ClearControllers() {
//
// SetFirstTargetName( "" );
// SetFirstController( blk_ref(-1) );
//
// //Cycle through all controllers, removing them as parents from the blocks they refer to
// for (uint i = 0; i < _children.size(); ++i ) {
// RemoveChild( _children[i].second.get_block() );
// }
//
// //Clear list
// _children.clear();
//}
void NiControllerSequence::SetTextKey( string new_name, blk_ref new_link ) {
//Set new name
txt_key_name = new_name;
//Check for identical block values
if ( new_link == txt_key_blk )
return;
//Remove old child
if ( txt_key_blk.is_null() == false ) {
RemoveChild( txt_key_blk.get_block() );
}
//Set new value
txt_key_blk = new_link;
//Add new child
if ( txt_key_blk.is_null() == false ) {
AddChild( txt_key_blk.get_block() );
}
}
void NiControllerSequence::AddKfChild( string new_name, blk_ref new_link, string controller_type = "" ) {
//Make sure the link isn't null
if ( new_link.is_null() == true ) {
throw runtime_error("Attempted to add a null link to NiControllerSequence block.");
}
KfChild kc;
kc.block = new_link;
//Check for a string palette
blk_ref str_pal = GetAttr("String Palette")->asLink();
if ( str_pal.is_null() == true ) {
//No string palette, store name internally
kc.name = new_name;
} else {
//String palette exists - store name and controller type there
//Make sure they didn't give us empty strings
if ( new_name.size() == 0 || controller_type.size() == 0 ) {
throw runtime_error( "You cannot use empty name or controller type strings when using a string palette.");
}
//Get palette
string pal = str_pal->GetAttr("Palette")->asString();
//--Search for copies of the text we want to add--//
//Search for the name string
int offset = (int)pal.find( new_name );
if ( offset == -1 ) {
//String not found, append it
kc.name_offset = (uint)pal.size();
pal.append( new_name + '\0' );
} else {
//String found, use existing offset
kc.name_offset = offset;
}
//Search for the controller type string
offset = (int)pal.find( controller_type );
if ( offset == -1 ) {
//String not found, append it
kc.controller_offset = (uint)pal.size();
pal.append( controller_type + '\0' );
} else {
//String found, use existing offset
kc.controller_offset = offset;
}
//Store the palette back to the string pal block
str_pal->GetAttr("Palette")->Set( pal );
}
children.push_back( kc );
//Add new child
AddChild( kc.block.get_block() );
//This should be impossible now, but don't want to forget it later
if ( kc.unk_link.is_null() != true ) {
AddChild( kc.unk_link.get_block() );
}
}
void NiControllerSequence::ClearKfChildren() {
//Cycle through all Kf Children, removing them as parents from the blocks they refer to
for (uint i = 0; i < children.size(); ++i ) {
if ( children[i].block.is_null() != true ) {
RemoveChild( children[i].block.get_block() );
}
if ( children[i].unk_link.is_null() != true ) {
RemoveChild( children[i].unk_link.get_block() );
}
}
//Clear list
children.clear();
//Check for a string palette
blk_ref str_pal = GetAttr("String Palette")->asLink();
if ( str_pal.is_null() == false ) {
//There's a string palette, so clear it out
str_pal->GetAttr("Palette")->Set( "" );
}
}
/***********************************************************
* NiFloatData methods
...
...
This diff is collapsed.
Click to expand it.
NIF_Blocks.h
+
3
−
3
View file @
182be3da
...
...
@@ -2153,9 +2153,9 @@ public:
}
//IControllerSequence Functions
/*
void SetTextKey( string new_name, blk_ref new_link );
void AddKfChild( string new_name, string controller_type
, blk_ref new_link
);
void ClearKfChildren();
*/
void
SetTextKey
(
string
new_name
,
blk_ref
new_link
);
void
AddKfChild
(
string
new_name
,
blk_ref
new_link
,
string
controller_type
);
void
ClearKfChildren
();
private
:
struct
KfChild
{
...
...
This diff is collapsed.
Click to expand it.
niflib.h
+
3
−
3
View file @
182be3da
...
...
@@ -2444,10 +2444,10 @@ public:
class
IControllerSequence
{
public:
IControllerSequence
()
{}
/*
virtual ~IControllerSequence () {}
virtual
~
IControllerSequence
()
{}
virtual
void
SetTextKey
(
string
new_name
,
blk_ref
new_link
)
=
0
;
virtual void AddKfChild( string new_name, string controller_type
, blk_ref new_link
) = 0;
virtual void ClearKfChildren() = 0;
*/
virtual
void
AddKfChild
(
string
new_name
,
blk_ref
new_link
,
string
controller_type
=
""
)
=
0
;
virtual
void
ClearKfChildren
()
=
0
;
};
/*! An advanced interface for the IPalette block which contains a color palette for internally stored paletized textures.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment