do_subtitles no longer tries to draw to the screen, thuscompleting one

more step in themain, audio, and graphics thread seperation.

Thiis also should illiminate all of the subtitle text overlap issues (bug232)


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@866 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
ghaushe
2003-03-07 17:57:03 +00:00
parent ffddaf54b4
commit 53b6ea685c
4 changed files with 44 additions and 16 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.3: Changes towards version 0.3:
- fix subtitle text overlap issues (bug 232)
- 'Esc' now leaves planet surface (bug233) -PhracturedBlue - 'Esc' now leaves planet surface (bug233) -PhracturedBlue
- Fix race on exiting starbase (bug 230) -PracturedBlue - Fix race on exiting starbase (bug 230) -PracturedBlue
- Cleanup shipyard door animation (bug 215) -PhracturedBlue - Cleanup shipyard door animation (bug 215) -PhracturedBlue
+40 -13
View File
@@ -101,6 +101,7 @@ enum
WAIT_SUBTITLE, WAIT_SUBTITLE,
}; };
static int subtitle_state = DONE_SUBTITLE; static int subtitle_state = DONE_SUBTITLE;
static Mutex subtitle_mutex;
/* _count_lines - mostly stolen from add_text, just sees how many lines /* _count_lines - mostly stolen from add_text, just sees how many lines
a given input string would take to display given the a given input string would take to display given the
@@ -472,6 +473,20 @@ xform_complete (void)
ClearSemaphore (XFormControl.XFormSem); ClearSemaphore (XFormControl.XFormSem);
} }
void
init_communication (void)
{
subtitle_mutex = CreateMutex ();
init_xform_control ();
}
void
uninit_communication (void)
{
DestroyMutex (subtitle_mutex);
uninit_xform_control ();
}
static BOOLEAN ColorChange; static BOOLEAN ColorChange;
static BOOLEAN ClearSubtitle = FALSE; static BOOLEAN ClearSubtitle = FALSE;
@@ -1148,6 +1163,15 @@ int ambient_anim_task(void* data)
{ {
CONTEXT OldContext; CONTEXT OldContext;
BOOLEAN CheckSub = 0; BOOLEAN CheckSub = 0;
BOOLEAN ClearSub;
int sub_state;
LockMutex (subtitle_mutex);
ClearSub = ClearSubtitle;
sub_state = subtitle_state;
ClearSubtitle = FALSE;
UnlockMutex (subtitle_mutex);
OldContext = SetContext (TaskContext); OldContext = SetContext (TaskContext);
@@ -1159,15 +1183,15 @@ int ambient_anim_task(void* data)
DrawAlienFrame (TalkFrame, &Sequencer[CommData.NumAnimations - 1]); DrawAlienFrame (TalkFrame, &Sequencer[CommData.NumAnimations - 1]);
CommData.AlienFrame = F; CommData.AlienFrame = F;
ColorChange = FALSE; ColorChange = FALSE;
ClearSubtitle = FALSE; ClearSub = FALSE;
CheckSub = 1; CheckSub = 1;
} }
if (Change || ClearSubtitle) if (Change || ClearSub)
{ {
STAMP s; STAMP s;
s.origin.x = -SAFE_X; s.origin.x = -SAFE_X;
s.origin.y = 0; s.origin.y = 0;
if (ClearSubtitle) if (ClearSub)
{ {
s.frame = CommFrame; s.frame = CommFrame;
DrawStamp (&s); DrawStamp (&s);
@@ -1175,14 +1199,14 @@ int ambient_anim_task(void* data)
i = CommData.NumAnimations; i = CommData.NumAnimations;
while (i--) while (i--)
{ {
if ((ClearSubtitle || FrameChanged[i])) if ((ClearSub || FrameChanged[i]))
{ {
s.frame = AnimFrame[i]; s.frame = AnimFrame[i];
DrawStamp (&s); DrawStamp (&s);
FrameChanged[i] = 0; FrameChanged[i] = 0;
} }
} }
if (ClearSubtitle && TransitionFrame) if (ClearSub && TransitionFrame)
{ {
s.frame = TransitionFrame; s.frame = TransitionFrame;
DrawStamp (&s); DrawStamp (&s);
@@ -1199,12 +1223,11 @@ int ambient_anim_task(void* data)
DrawStamp (&s); DrawStamp (&s);
TalkFrameChanged = FALSE; TalkFrameChanged = FALSE;
} }
ClearSubtitle = FALSE;
Change = FALSE; Change = FALSE;
CheckSub = 1; CheckSub = 1;
} }
if (CheckSub && subtitle_state >= SPACE_SUBTITLE) if (CheckSub && sub_state >= SPACE_SUBTITLE)
{ {
TEXT t; TEXT t;
@@ -2040,8 +2063,13 @@ int
do_subtitles (UNICODE *pStr) do_subtitles (UNICODE *pStr)
{ {
static UNICODE *last_page = NULL; static UNICODE *last_page = NULL;
LockMutex (subtitle_mutex);
if (pStr == 0) if (pStr == 0)
return (subtitle_state = DONE_SUBTITLE); {
subtitle_state = DONE_SUBTITLE;
UnlockMutex (subtitle_mutex);
return (subtitle_state);
}
else if (pStr == (void *)~0) else if (pStr == (void *)~0)
{ {
subtitle_state = WAIT_SUBTITLE; subtitle_state = WAIT_SUBTITLE;
@@ -2049,7 +2077,10 @@ do_subtitles (UNICODE *pStr)
else else
{ {
if (last_page == pStr) if (last_page == pStr)
{
UnlockMutex (subtitle_mutex);
return (subtitle_state); return (subtitle_state);
}
subtitle_state = READ_SUBTITLE; subtitle_state = READ_SUBTITLE;
ClearSubtitle = TRUE; ClearSubtitle = TRUE;
// fprintf (stderr, "changed page to: %d\n", cur_page); // fprintf (stderr, "changed page to: %d\n", cur_page);
@@ -2061,7 +2092,6 @@ do_subtitles (UNICODE *pStr)
case READ_SUBTITLE: case READ_SUBTITLE:
{ {
TEXT t; TEXT t;
CONTEXT OldContext;
if (optSubtitles) if (optSubtitles)
{ {
@@ -2073,10 +2103,6 @@ do_subtitles (UNICODE *pStr)
} }
t = CommData.AlienTextTemplate; t = CommData.AlienTextTemplate;
OldContext = SetContext (TaskContext);
add_text (1, &t);
SetContext (OldContext);
CommData.AlienTextTemplate.CharCount = t.pStr - CommData.AlienTextTemplate.pStr; CommData.AlienTextTemplate.CharCount = t.pStr - CommData.AlienTextTemplate.pStr;
subtitle_state = WAIT_SUBTITLE; subtitle_state = WAIT_SUBTITLE;
break; break;
@@ -2089,6 +2115,7 @@ do_subtitles (UNICODE *pStr)
case DONE_SUBTITLE: case DONE_SUBTITLE:
break; break;
} }
UnlockMutex (subtitle_mutex);
return (subtitle_state); return (subtitle_state);
} }
+2 -2
View File
@@ -17,7 +17,7 @@
#ifndef _COMM_H #ifndef _COMM_H
#define _COMM_H #define _COMM_H
void init_xform_control (void); void init_communication (void);
void uninit_communication (void);
#endif /* _COMM_H */ #endif /* _COMM_H */
+1 -1
View File
@@ -317,7 +317,7 @@ main (int argc, char *argv[])
GraphicsSem = CreateSemaphore (1, "Graphics"); GraphicsSem = CreateSemaphore (1, "Graphics");
RenderingCond = CreateCondVar (); RenderingCond = CreateCondVar ();
init_xform_control (); init_communication ();
TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp); TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp);
TFB_SetGamma (gamma); TFB_SetGamma (gamma);