📄 libgnome-gnome-score.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>gnome-score</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"><link rel="start" href="index.html" title="GNOME Library Reference Manual"><link rel="up" href="ch01s03.html" title="Displaying help and external info"><link rel="prev" href="libgnome-gnome-url.html" title="gnome-url"><link rel="next" href="ch01s04.html" title="Miscellaneous"><meta name="generator" content="GTK-Doc V1.7 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="libgnome.html" title="GNOME Library (libgnome)"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="libgnome-gnome-url.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="ch01s03.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GNOME Library Reference Manual</th><td><a accesskey="n" href="ch01s04.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id2820885" class="shortcut">Top</a>  |  <a href="#id2821013" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="libgnome-gnome-score"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id2820885"></a><span class="refentrytitle">gnome-score</span></h2><p>gnome-score — Tracking best scores for games</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include <libgnome/libgnome.h><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a href="libgnome-gnome-score.html#gnome-score-init">gnome_score_init</a> (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *gamename);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a href="libgnome-gnome-score.html#gnome-score-log">gnome_score_log</a> (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gfloat">gfloat</a> score, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *level, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> higher_to_lower_score_order);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <a href="libgnome-gnome-score.html#gnome-score-get-notable">gnome_score_get_notable</a> (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *gamename, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *level, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> ***names, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gfloat">gfloat</a> **scores, time_t **scoretimes);</pre></div><div class="refsect1" lang="en"><a name="id2821013"></a><h2>Description</h2><p>The routines in this module provide a simple way to keep track of users' scoresin a game.</p><p>In order to acommodate file ownership permissions, the game application shouldbe installed setgid <em class="wordasword">games</em> and the scoretable shouldonly be writable by the <em class="wordasword">games</em> group. The programshould call <a href="libgnome-gnome-score.html#gnome-score-init"><code class="function">gnome_score_init()</code></a> as soon as possible inside the <code class="function">main()</code> routine.This will open a pair of pipes to a child process which can read and write thescore table and then will drop the group privileges of the main program back tothe user's normal group id.</p></div><div class="refsect1" lang="en"><a name="id2821068"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2821078"></a><h3><a name="gnome-score-init"></a>gnome_score_init ()</h3><a class="indexterm" name="id2821093"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> gnome_score_init (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *gamename);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_score_init</code> is deprecated and should not be used in newly-written code.</p></div><p>GNOME games should call this routine as the first statementin <code class="function">main()</code> if they have been installed setgid to the "games" group. Itperforms the intialization required to later record information in thescores table and then drops the groups privileges.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>gamename</code></em> :</span></td><td> Identifies the game name.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">0</code> on success, returns <code class="literal">-1</code> on failure.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2821201"></a><h3><a name="gnome-score-log"></a>gnome_score_log ()</h3><a class="indexterm" name="id2821216"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> gnome_score_log (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gfloat">gfloat</a> score, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *level, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> higher_to_lower_score_order);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_score_log</code> is deprecated and should not be used in newly-written code.</p></div><p>Logs a score entry for the user. You should call this every time a gameends. This function takes care of working out whether the user's score madeit into the ten best scores and, if so, records it in the table.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>score</code></em> :</span></td><td> The score achieved by the user in this game</td></tr><tr><td><span class="term"><em class="parameter"><code>level</code></em> :</span></td><td> The level on which the score was obtained</td></tr><tr><td><span class="term"><em class="parameter"><code>higher_to_lower_score_order</code></em> :</span></td><td> Set to <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if high scores are better thanlow scores.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> <code class="literal">0</code> on failure or the status from the gnome-score helperprogram.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2821358"></a><h3><a name="gnome-score-get-notable"></a>gnome_score_get_notable ()</h3><a class="indexterm" name="id2821373"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> gnome_score_get_notable (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *gamename, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *level, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> ***names, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gfloat">gfloat</a> **scores, time_t **scoretimes);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gnome_score_get_notable</code> is deprecated and should not be used in newly-written code.</p></div><p>Fetches the most notable players on <em class="parameter"><code>gamename</code></em> at level <em class="parameter"><code>level</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>gamename</code></em> :</span></td><td> The name of the game we want to fetch information from.</td></tr><tr><td><span class="term"><em class="parameter"><code>level</code></em> :</span></td><td> The level for which we want to pull information.</td></tr><tr><td><span class="term"><em class="parameter"><code>names</code></em> :</span></td><td> An array of strings is returned at the address pointed here</td></tr><tr><td><span class="term"><em class="parameter"><code>scores</code></em> :</span></td><td> An array of gfloats is returned at the address pointed here</td></tr><tr><td><span class="term"><em class="parameter"><code>scoretimes</code></em> :</span></td><td> An array of time_t is returned at the address pointed here</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> The number of scores returned. The <em class="parameter"><code>names</code></em>, <em class="parameter"><code>scores</code></em> and <em class="parameter"><code>scoretime</code></em>pointers point to regions that were allocated with <ahref="/usr/share/gtk-doc/html/glib/glib-Memory-Allocation.html#g-malloc"><code class="function">g_malloc()</code></a> with thecontents.</td></tr></tbody></table></div></div></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -