Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jasonrohrer/OneLife
Browse files Browse the repository at this point in the history
  • Loading branch information
skps2010 committed Oct 7, 2023
2 parents 097e18c + 20fbe64 commit 1fda73e
Show file tree
Hide file tree
Showing 17 changed files with 359 additions and 19 deletions.
23 changes: 22 additions & 1 deletion documentation/changeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,32 @@ http://onehouronelife.com/updateLog.php



Version 393 ???
Version 394 2023-October-6

--New /MOTHER command to locate your mother (sometimes she's not your leader,
so the /LEADER command doesn't always work to find her). Fixes #926

--Support for using extra animation slots in emotes.




Editor Fixes:

--Made animation freeze slider in scene editor cover more time range, to be
able to feeze action later in an animation.

--Sound widget now has text field for volume instead of just a slider, making
even quieter volumes settable.

--Animation editor can now clone extras animations from one person to all other
people, with intelligent matching of sprites (with same position and age
range).

--Animation editor can now clone extras from one person object to another.

--Scene editor can now display gesture emotes.




Expand Down
205 changes: 204 additions & 1 deletion gameSource/EditorAnimationPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,20 @@ EditorAnimationPage::EditorAnimationPage()
mFullSoundPasteButton( smallFont, 130, -328, "Full Sound Paste" ),
mSpeedMultField( smallFont, -500, -328, 4, false,
"Speed x", "0123456789." ),
mSpeedMultApplyButton( smallFont, -446, -328, "Apply" ) {
mSpeedMultApplyButton( smallFont, -446, -328, "Apply" ),
mCloneExtrasToOtherPeopleButton(
smallFont, 390, 310,
"Clone Extras to All People" ),
mCloneExtrasToOtherPeopleButtonConfirm(
smallFont, 190, 310,
"Really?" ),
mCopyExtrasButton(
smallFont, 560, 310,
"Copy Extras" ),
mClonedExtrasObjectID( -1 ),
mPasteClonedExtrasButton(
smallFont, 190, 310,
"Paste Extras and Save" ) {


for( int i=0; i<=extraB; i++ ) {
Expand Down Expand Up @@ -536,6 +549,23 @@ EditorAnimationPage::EditorAnimationPage()
addKeyDescription( &mKeyLegend, 'h', "Hide/show UI" );

addKeyClassDescription( &mKeyLegendB, "R-Click", "Copy animations" );


addComponent( &mCloneExtrasToOtherPeopleButton );
addComponent( &mCloneExtrasToOtherPeopleButtonConfirm );
addComponent( &mCopyExtrasButton );

mCloneExtrasToOtherPeopleButton.addActionListener( this );
mCloneExtrasToOtherPeopleButtonConfirm.addActionListener( this );
mCopyExtrasButton.addActionListener( this );

mCloneExtrasToOtherPeopleButton.setVisible( false );
mCloneExtrasToOtherPeopleButtonConfirm.setVisible( false );
mCopyExtrasButton.setVisible( false );

addComponent( &mPasteClonedExtrasButton );
mPasteClonedExtrasButton.addActionListener( this );
mPasteClonedExtrasButton.setVisible( false );
}


Expand Down Expand Up @@ -681,6 +711,136 @@ static AnimationRecord *createRecordForObject( int inObjectID,



static void cloneExtrasBetweenPeople( int inSourceObjectID,
int inDestObjectID ) {

ObjectRecord *sourceO = getObject( inSourceObjectID );

ObjectRecord *currentO = getObject( inDestObjectID );


// clear the old ones first, because we might have a
// different number of extras now
int oldExtras = getNumExtraAnim( inDestObjectID );

for( int i=0; i<oldExtras; i++ ) {
setExtraIndex( i );
clearAnimation( inDestObjectID, extra );
}


int newExtras = getNumExtraAnim( inSourceObjectID );


for( int i=0; i < newExtras; i++ ) {
setExtraIndex( i );

AnimationRecord *newRecord =
createRecordForObject( inDestObjectID, extra );

AnimationRecord *sourceRecord = getAnimation( inSourceObjectID,
extra );

delete [] newRecord->soundAnim;

newRecord->numSounds = sourceRecord->numSounds;

newRecord->soundAnim =
new SoundAnimationRecord[ newRecord->numSounds ];
for( int s=0; s < newRecord->numSounds; s++ ) {
newRecord->soundAnim[s] =
copyRecord( sourceRecord->soundAnim[s] );
}


for( int s=0; s < sourceRecord->numSlots; s++ ) {
if( s < currentO->numSlots ) {
newRecord->slotAnim[s] = sourceRecord->slotAnim[s];
}
}



// walk through each sprite animation in sourceRecord
// For each one, look at sprite's:
// --id
// --position
// --age start and end
// Then walk through the inDestObjectID object and look
// for a sprite that matches all three of these things
//
// --If found, copy that sprite animation into the corresponding
// slot in newRecord

for( int s=0; s < sourceRecord->numSprites; s++ ) {

int id = sourceO->sprites[s];
doublePair pos = sourceO->spritePos[s];

double ageStart = sourceO->spriteAgeStart[s];
double ageEnd = sourceO->spriteAgeEnd[s];


for( int s2=0; s2 < currentO->numSprites; s2++ ) {

if( currentO->sprites[s2] == id
&&
equal( currentO->spritePos[s2], pos )
&&
currentO->spriteAgeStart[s2] == ageStart
&&
currentO->spriteAgeEnd[s2] == ageEnd ) {

// a match

newRecord->spriteAnim[s2] =
sourceRecord->spriteAnim[s];
}
}
}
addAnimation( newRecord );

freeRecord( newRecord );
}
}





// clone extra animations from inSourceObjectID to all other person objects
// in the object bank
static void cloneExtrasToOtherPeople( int inSourceObjectID ) {

int firstPersonID = getNextPersonObject( -1 );

int currentPersonID = firstPersonID;




while( true ) {

if( currentPersonID == inSourceObjectID ) {
// skip source person
currentPersonID = getNextPersonObject( currentPersonID );
continue;
}

cloneExtrasBetweenPeople( inSourceObjectID, currentPersonID );

currentPersonID = getNextPersonObject( currentPersonID );

// looped back around
if( currentPersonID == firstPersonID ) {
break;
}
}
}




void EditorAnimationPage::populateCurrentAnim() {
freeCurrentAnim();

Expand Down Expand Up @@ -832,6 +992,12 @@ void EditorAnimationPage::checkNextPrevVisible() {
mCopyChainRandButton.setVisible( false );
mCopyWalkButton.setVisible( false );
mCopyUpButton.setVisible( false );

mCloneExtrasToOtherPeopleButton.setVisible( false );
mCloneExtrasToOtherPeopleButtonConfirm.setVisible( false );

mPasteClonedExtrasButton.setVisible( false );
mCopyExtrasButton.setVisible( false );
return;
}

Expand Down Expand Up @@ -874,9 +1040,19 @@ void EditorAnimationPage::checkNextPrevVisible() {

if( r->person ) {
mCopyWalkButton.setVisible( true );
mCloneExtrasToOtherPeopleButton.setVisible( true );
mCloneExtrasToOtherPeopleButtonConfirm.setVisible( false );
mCopyExtrasButton.setVisible( true );

if( mClonedExtrasObjectID > 0 &&
mCurrentObjectID != mClonedExtrasObjectID ) {
mPasteClonedExtrasButton.setVisible( true );
}
}
else {
mCopyWalkButton.setVisible( false );
mCloneExtrasToOtherPeopleButton.setVisible( false );
mCloneExtrasToOtherPeopleButtonConfirm.setVisible( false );
}


Expand Down Expand Up @@ -2444,6 +2620,33 @@ void EditorAnimationPage::actionPerformed( GUIComponent *inTarget ) {
mSpeedMultField.setText( "1.0" );
}
}
else if( inTarget == &mCloneExtrasToOtherPeopleButton ) {
mCloneExtrasToOtherPeopleButton.setVisible( false );
mCloneExtrasToOtherPeopleButtonConfirm.setVisible( true );
}
else if( inTarget == &mCloneExtrasToOtherPeopleButtonConfirm ) {
mCloneExtrasToOtherPeopleButton.setVisible( false );
mCloneExtrasToOtherPeopleButtonConfirm.setVisible( false );

cloneExtrasToOtherPeople( mCurrentObjectID );

mClonedExtrasObjectID = mCurrentObjectID;
}
else if( inTarget == &mCopyExtrasButton ) {
mClonedExtrasObjectID = mCurrentObjectID;
mCopyExtrasButton.setVisible( false );
}
else if( inTarget == &mPasteClonedExtrasButton ) {
cloneExtrasBetweenPeople( mClonedExtrasObjectID, mCurrentObjectID );

// re-pick current object
actionPerformed( &mObjectPicker );

// switch to extras
actionPerformed( mCheckboxes[5] );

mPasteClonedExtrasButton.setVisible( false );
}
else {

AnimType oldType = mCurrentType;
Expand Down
10 changes: 10 additions & 0 deletions gameSource/EditorAnimationPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,16 @@ class EditorAnimationPage : public GamePage, public ActionListener {
TextField mSpeedMultField;
TextButton mSpeedMultApplyButton;


TextButton mCloneExtrasToOtherPeopleButton;
TextButton mCloneExtrasToOtherPeopleButtonConfirm;

TextButton mCopyExtrasButton;

int mClonedExtrasObjectID;

TextButton mPasteClonedExtrasButton;


void checkNextPrevVisible();

Expand Down
16 changes: 14 additions & 2 deletions gameSource/EditorScenePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ EditorScenePage::EditorScenePage()
true, 2 ),
mCellAnimFreezeSlider( smallFont, -450, -340, 2,
300, 20,
-2, 2, "Cell Time" ),
-2, 4, "Cell Time" ),
mPersonAnimFreezeSlider( smallFont, 50, -340, 2,
300, 20,
-2, 2, "Person Time" ),
Expand Down Expand Up @@ -1493,6 +1493,18 @@ void EditorScenePage::drawUnderComponents( doublePair inViewCenter,

ClothingSet clothingToDraw = p->clothing;

AnimType aType = p->anim;


// for now, only first emote in comma-separated
// list of emots can have extra anim associated
// with it
if( p->currentEmot != NULL &&
p->currentEmot->extraAnimIndex > -1 ) {
aType = extra;
setExtraIndex( p->currentEmot->extraAnimIndex );
}

if( splitHeld ) {
// don't actually draw person now
// sandwitch them in between layers of
Expand All @@ -1506,7 +1518,7 @@ void EditorScenePage::drawUnderComponents( doublePair inViewCenter,
drawObjectAnim( p->oID, 2, p->anim,
thisFrameTime,
0,
p->anim,
aType,
thisFrameTime,
frozenRotFrameTime,
&used,
Expand Down
Loading

0 comments on commit 1fda73e

Please sign in to comment.